Create a FilteredElementCollector

Create a FilteredElementCollector

The main class used for element iteration and filtering is called FilteredElementCollector. It is constructed in one of three ways:

  1. From a document - will search and filter the set of elements in a document
  2. From a document and set of ElementIds - will search and filter a specified set of elements
  3. From a document and a view - will search and filter the visible elements in a view
Note: Always check that a view is valid for element iteration when filtering elements in a specified view by using the static FilteredElementCollector.IsViewValidForElementIteration().

When the object is first created, there are no filters applied. This class requires that at least one condition be set before making at attempt to access the elements, otherwise an exception will be thrown.