FilteredElementCollector - OfCategory Accepts 2 Arguments 1 given

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.

gms = []
toggle = IN[0]

if toggle == True:
collector = FilteredElementCollector.OfCategory(BuiltInCategory.OST_GenericModel)
for col in collector:
gms.append(col)
else:
pass
#Assign your output to the OUT variable.
OUT = gms

Does anybody know what the second argument could be? I am building this script in Revit 2018.3 and Dynamo version 1.3. The reason being I need the script to work for everyone in the company and on different versions of Dynamo and Revit. Hence why I am trying to select generic models with Python.

Hi @simon_murphy1,

You missed the Revit document argument.

import clr
clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
#The inputs to this node will be stored as a list in the IN variables.

toggle = IN[0]

if toggle == True:
	collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_GenericModel).WhereElementIsNotElementType().ToElements()
else:
	pass
#Assign your output to the OUT variable.
OUT = collector

Collector

1 Like