Multiple class filter

im trying to use a ElementMulticlassFilter with filtered element collector and i dont know how to cast a python list of classes to a c# List<Type> like its specified in the api docs.
https://www.revitapidocs.com/2021.1/6d3c931c-81a3-4b6f-d9ac-e2e714c93db1.htm

i tried using System.Object but it’s not working.
Here is the code

Classes = [Duct, Pipe]
TypedClasses = List[System.Object](Classes)
multiClassFilter = ElementMulticlassFilter(TypedClasses)
wantedElementes = FilteredElementCollector(doc).WherePasses(wantedElementes).ToElements()

also tried something like this

type1=System.Object.GetType(Element)
TypedClasses = List[type1](Classes)

and the error is > Expected IList got List

Does anyone know what is the problem?

Hi @Andrej.Licanin I think it will work like this:

TypedClasses = List[System.Type]()
TypedClasses.Add(MEPCurve)
multiClassFilter = ElementMulticlassFilter(TypedClasses)
wantedElementes = FilteredElementCollector(doc).WherePasses(multiClassFilter).ToElements()
OUT = wantedElementes
4 Likes

Worked, thank you :smiley:

1 Like