FilteredElementCollector.GetElementIdIterator
Public Class
InvalidOperationException
Returns an element id iterator to the elements passing the filters.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public FilteredElementIdIterator GetElementIdIterator()Return Value
FilteredElementIdIteratorExceptions
Exception
Condition
InvalidOperationException
The collector does not have a filter applied. Extraction or iteration of elements is not permitted without a filter.
Remarks
Calling this when you have an active iterator to this same collector will result in the first iterator being stopped by this call.
Example
// Use a RoomFilter to find all room elements in the document.RoomFilter filter = new RoomFilter();
// Apply the filter to the elements in the active documentFilteredElementCollector collector = new FilteredElementCollector(document);collector.WherePasses(filter);
// Get results as ElementId iteratorFilteredElementIdIterator roomIdItr = collector.GetElementIdIterator();roomIdItr.Reset();while (roomIdItr.MoveNext()){ ElementId roomId = roomIdItr.Current; // Warn rooms smaller than 50 SF Room room = document.GetElement(roomId) as Room; if (room.Area < 50.0) { String prompt = "Room is too small: id = " + roomId.ToString(); TaskDialog.Show("Revit", prompt); break; }}