Get all the elements inside the viewports ..help!

Good day.
Help please…I’m trying to get all the items inside the VIEWPORTS…
Could someone please help me find the correct syntax … thank you very much


ALL ELEMENTS IN VIEWPORTS.rvt (4.7 MB)

VISTAS ENCONTRADAS EN PLANOS.dyn (3.9 KB)

Use the viewport ViewId property to get the View. Then use that view.Id in the filtered collector.

InVP = FilteredElementCollector(doc,view.Id).ToElements()

2 Likes

the “FIilteredElementCollector(doc,id).ToElements()” syntax returns elements that are inside views, but not views.
What would be the syntax to get only the views?

InVP = FilteredElementCollector(doc,view.Id).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements()

1 Like

Good morning,
I tried with your code but I can’t do it (it comes from me it’s almost certain)

# Get the current document
doc = DocumentManager.Instance.CurrentDBDocument

ele_byview=[]
vues=[]
col_viewport=FilteredElementCollector(doc,doc.ActiveView.Id).OfClass(Viewport).WhereElementIsNotElementType().ToElements()

for i in col_viewport:
    col_ele=FilteredElementCollector(doc,i.ViewId).WhereElementIsNotElementType().ToElements()
    ele_byview.append(col_ele)
    col_vue=FilteredElementCollector(doc,i.ViewId).OfCategory(BuiltInCategory.OST_Views).WhereElementIsNotElementType().ToElements()
    vues.append(col_vue)

OUT=col_viewport,ele_byview,vues

image

is this the right class to get the View from the Viewport

edit: I found a solution from Mr. Pierson

Cordially
christian.stan

1 Like

Can these two nodes solve your problem? This flow works for our project for counting elements on sheets, but it has some limitations when elements are close to the boundary of match lines in views.