Hello, please advise on how to get linked rooms visible in ActiveView.
From a reference dynamo manual I saw a method for doing this using solids but I wasn’t very successful at intersecting the room solids with the Active View solid (bounding box maybe?)
My other approach then has become this one:
# Access the document of the link
linkDocu = link.GetLinkDocument() # link is of type 'RevitLinkInstance'
# Get linked rooms
cat = DB.BuiltInCategory.OST_Rooms
filter = DB.ElementCategoryFilter(cat)
Type = doc.GetElement(link.GetTypeId())
if RevitLinkType.IsLoaded(doc, Type.Id):
cuartos = DB.FilteredElementCollector(linkDocu).WherePasses(filter).WhereElementIsNotElementType().ToElements()
print(len(cuartos)) # Check: 986 rooms in the link. OK cool but I just want the ones visible in the active view!!
# Tried the overload of FEC constructor "Autodesk.Revit.Exceptions.ArgumentException: viewId is not a view"
test = DB.FilteredElementCollector(linkDocu, doc.ActiveView.Id).WherePasses(filter).WhereElementIsNotElementType().ToElements()
# Using quick filters doesnt work either, "Autodesk.Revit.Exceptions.ArgumentException: viewId is not valid for element iteration, because it has no way of representing drawn elements. Many view templates will fail this check."
qk_Cat_filter1 = DB.ElementCategoryFilter(DB.BuiltInCategory.OST_Rooms)
qk_Cat_filter2 = DB.VisibleInViewFilter(linkDocu, cuartos[0].Id, False)
# Also tried passing LinkElementId but same error
# r_ID = LinkElementId(link.Id,cuartos[0].Id)
linked = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_RvtLinks).WhereElementIsNotElementType().FirstElement()
linkDoc = linked.GetLinkDocument()
all_rooms = FilteredElementCollector(linkDoc, activeView).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()
names = [i.get_Parameter(BuiltInParameter.ROOM_NAME).AsString() for i in all_rooms]
for i in names:
print(i)
Thanks @andreasd811 I tried your code but I still get the same error. I always thought FilteredElementCollector(linkDoc, activeView) does not work for link documents? Also does your link have multiple rooms in multiple floors or just in that floor? That might be something to look at also