Open JacobSmall opened 7 years ago
Tags have a custom element wrapper and that tries to verify the host of the tag:
https://github.com/DynamoDS/DynamoRevit/blob/Revit2018/src/Libraries/RevitNodes/Elements/Tag.cs#L39
Something is causing that to fail. My guess is the host property, because that's null for tags of linked elements. One possible workaround is to force the use of the unknown element wrapper instead:
I'll push the changes in the next release. Here's a snippet:
import clr
clr.AddReference("RevitServices")
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
clr.AddReference("RevitAPI")
from Autodesk.Revit.DB import FilteredElementCollector
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
def tolist(obj1):
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
views = UnwrapElement(tolist(IN[0]) )
cat = UnwrapElement(IN[1])
OUT = []
ueWrapper = None
wrappers = clr.GetClrType(Revit.Elements.ElementWrapper).GetMethods()
for w in wrappers:
if w.ToString().startswith("Revit.Elements.UnknownElement"):
ueWrapper = w
break
if ueWrapper is not None:
for i in xrange(len(views)):
fec = FilteredElementCollector(doc, views[i].Id).WhereElementIsNotElementType()
if cat is not None:
fec = fec.OfCategoryId(cat.Id)
view_el = []
for e in fec:
view_el.append(ueWrapper.Invoke(None, (e, True) ) )
OUT.append(view_el)
However that approach has one major limitation - any revit node that requires a specific sub-type of the element class will fail to work...
Nice, although WOW that seems to be very computationally heavy! Any thoughts?
thanks @dimven this workaround just saved me! Issue not only applicable to linked elements.
This is still and issue and you can't even "select" and element like this either.
Posted to the dynamo forum and multiple other users confirmed the issue exists for them as well. See post here: //forum.dynamobim.com/t/selecting-tags-associated-to-a-linked-model/16118
Dynamo version
1.2.1
Revit version
2017.2
Operating system
Windows 7
What did you do?
Attempted multiple methods to select tags associated with elements in a linked model. All elements of category, all elements of type, elements in view, select model element, select model elements, IDs to element, and multiple UI selection methods from various packages were tried.
What did you expect to see?
Selected Revit elements for use in dynamo environment.
What did you see instead?
Error messages or 'null' in all cases. See attached screenshot of error and screenshot of packages installed (incase it's package related as the forum thought that may be part of the cause).