Hi,
main goal
I want to use the FilteredElementCollector in order to collect elements in my project and within the Links in my project.
My problem
My question is how do I collect only the elements that are in my current view?
Im not sure about what I tried because I am working on a big file with multiple Revit Links and when I try to print the elements I get an endless list of elements inside every Link, which doesnt seem right given the fact that my current view is a section with not a lot of elements in it.
link_doc.ActiveView.Id
gets a NoneType error…
But when not passing an active view I get that endless list of elements I mentioned
My script
#######################################
# VARIABLES
#######################################
doc = __revit__.ActiveUIDocument.Document # type: Document
uidoc = __revit__.ActiveUIDocument # type: UIDocument
selection = uidoc.Selection # type: Selection
#######################################
# MAIN
#######################################
# Collect all Revit Links instances
revit_link_instances_collector = FilteredElementCollector(doc, active_view.Id).OfClass(RevitLinkInstance).ToElements()
for link in revit_link_instances_collector:
# Get the doc for current Link
link_doc = link.GetLinkDocument()
if link_doc:
# collect all FamilyInstances
linked_elemens = FilteredElementCollector(link_doc, link_doc.ActiveView.Id).OfClass(FamilyInstance).WhereElementIsNotElementType().ToElements()
for element in linked_elemens:
print(element)