Skip to main content

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

  1. Import the necessary library:

    import System
    from System.Collections.Generic import *
  2. Construct a strongly typed list:

    typeList = List[System.Type]()
    typeList.Add(Floor)
    typeList.Add(Wall)
  3. Create an instance of ElementMulticlassFilter:

    emcf = ElementMulticlassFilter(typeList)
  4. 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.