I want to feed a node a single view element and get a list of elements visible in that view, specifically Revit links. This is easy for the active view, because there is the built in node “All Elements in Active View”. But I can’t set the active view programmatically and would prefer to iterate the views with a collector and return the elements that are visible.
This is the snippet of code I can’t get to work. I nkow that the viewElem.Id is right, but I’m guess something about my category statement is wrong:
listed = list()
listed.append(FilteredElementCollector(doc,viewElem.Id).WhereElementIsNotElementType().OfCategory(BuiltInCategory(OST_RvtLinks)).ToElementIds())
Full code:
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *
Import DocumentManager
clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
Import RevitAPI
clr.AddReference(“RevitAPI”)
import Autodesk
Import ToDSType(bool) extension method
clr.AddReference(“RevitNodes”)
import Revit
from Autodesk.Revit.DB import *
clr.ImportExtensions(Revit.Elements)
import System
viewElem = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
listed = list()
listed.append(FilteredElementCollector(doc,viewElem.Id).WhereElementIsNotElementType().OfCategory(BuiltInCategory(OST_RvtLinks)).ToElementIds())
OUT = listed
<span style=“color: #f92672; font-weight: bold;”> </span>