FilteredElementCollectorFirstElement Method |
Returns the first element to pass the filter(s).
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic Element FirstElement()
Public Function FirstElement As Element
public:
Element^ FirstElement()
member FirstElement : unit -> Element
Return Value
Element
The first element.
ExceptionsException | Condition |
---|
InvalidOperationException |
The collector does not have a filter applied. Extraction or iteration of elements is not permitted without a filter.
|
Remarks
This will reset the collector to the beginning and find the first element that passes the applied filter(s).
If you have an active iterator to this same collector it will be stopped by this call.
Examplepublic FamilyInstance GetAColumn(Autodesk.Revit.DB.Document document)
{
StructuralInstanceUsageFilter columnFilter =
new StructuralInstanceUsageFilter(StructuralInstanceUsage.Column);
FilteredElementCollector collector = new FilteredElementCollector(document);
collector.WherePasses(columnFilter);
FamilyInstance column = collector.FirstElement() as FamilyInstance;
return column;
}
Public Function GetAColumn(document As Autodesk.Revit.DB.Document) As FamilyInstance
Dim columnFilter As New StructuralInstanceUsageFilter(StructuralInstanceUsage.Column)
Dim collector As New FilteredElementCollector(document)
collector.WherePasses(columnFilter)
Dim column As FamilyInstance = TryCast(collector.FirstElement(), FamilyInstance)
Return column
End Function
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also