Get all the elements inside the viewports ..help!

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

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