Filter Multiple Classes
Overview
A quick filter represented in the API by ElementMultiClassFilter
allows searching for elements whose class matches any of those inserted as arguments by means of a set. These data sets must be strongly typed.
Example
-
Import the necessary library:
import System
from System.Collections.Generic import * -
Construct a strongly typed list:
typeList = List[System.Type]()
typeList.Add(Floor)
typeList.Add(Wall) -
Create an instance of
ElementMulticlassFilter
:emcf = ElementMulticlassFilter(typeList)
-
Apply the filter to the collector:
elems = FilteredElementCollector(doc).WherePasses(emcf).ToElements()
Note
To define the classes, the RevitAPI library must be imported. Without it, the script will throw an exception indicating that the variables Floor
and Wall
have not been defined.