GetElementIterator Method


Returns an element iterator to the elements passing the filters.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since: 2011

Syntax

C#
public FilteredElementIterator GetElementIterator()
Visual Basic
Public Function GetElementIterator As FilteredElementIterator
Visual C++
public:
FilteredElementIterator^ GetElementIterator()

Remarks

Calling this when you have an active iterator to this same collector will result in the first iterator being stopped by this call.

Examples

Copy C#
FilteredElementCollector collector = new FilteredElementCollector(document);

// Apply a filter to get all pipes in the document
collector.OfClass(typeof(Autodesk.Revit.DB.Plumbing.Pipe));

// Get results as an element iterator and look for a pipe with
// a specific flow state
FilteredElementIterator elemItr = collector.GetElementIterator();
elemItr.Reset();
while (elemItr.MoveNext())
{
    Pipe pipe = elemItr.Current as Pipe;
    if (pipe.FlowState == PipeFlowState.LaminarState)
    {
        TaskDialog.Show("Revit", "Model has at least one pipe with Laminar flow state.");
        break;
    }
}
Copy VB.NET
Dim collector As New FilteredElementCollector(document)

' Apply a filter to get all pipes in the document
collector.OfClass(GetType(Autodesk.Revit.DB.Plumbing.Pipe))

' Get results as an element iterator and look for a pipe with
' a specific flow state
Dim elemItr As FilteredElementIterator = collector.GetElementIterator()
elemItr.Reset()
While elemItr.MoveNext()
    Dim pipe As Pipe = TryCast(elemItr.Current, Pipe)
    If pipe.FlowState = PipeFlowState.LaminarState Then
        TaskDialog.Show("Revit", "Model has at least one pipe with Laminar flow state.")
        Exit While
    End If
End While

Exceptions

Exception Condition
Autodesk.Revit.Exceptions InvalidOperationException The collector does not have a filter applied. Extraction or iteration of elements is not permitted without a filter.

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →