Constructs a new FilteredElementCollector that will search and filter the visible elements in a view.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)
Since:
2011
Syntax
Remarks
Examples
CopyC#
private void CountElements(UIDocument uiDoc)
{
StringBuilder message = new StringBuilder();
FilteredElementCollector viewCollector =
new FilteredElementCollector(uiDoc.Document, uiDoc.ActiveView.Id);
viewCollector.OfCategory(BuiltInCategory.OST_Walls);
message.AppendLine("Wall category elements within active View: "
+ viewCollector.ToElementIds().Count);
FilteredElementCollector docCollector = new FilteredElementCollector(uiDoc.Document);
docCollector.OfCategory(BuiltInCategory.OST_Walls);
message.AppendLine("Wall category elements within document: "
+ docCollector.ToElementIds().Count);
TaskDialog.Show("Revit", message.ToString());
}
CopyC#
public static void GetScheduleContents(ViewSchedule viewSchedule)
{
FilteredElementCollector typeCollector = new FilteredElementCollector(viewSchedule.Document, viewSchedule.Id);
typeCollector.WhereElementIsElementType();
int numberOfTypes = typeCollector.Count();
FilteredElementCollector instCollector = new FilteredElementCollector(viewSchedule.Document, viewSchedule.Id);
instCollector.WhereElementIsNotElementType();
int numberOfInstances = instCollector.Count();
TaskDialog.Show("Elements in schedule", String.Format("Types {0} instances {1}", numberOfTypes, numberOfInstances));
}
CopyVB.NET
Private Sub CountElements(uiDoc As UIDocument)
Dim message As New StringBuilder()
Dim viewCollector As New FilteredElementCollector(uiDoc.Document, uiDoc.ActiveView.Id)
viewCollector.OfCategory(BuiltInCategory.OST_Walls)
message.AppendLine("Wall category elements within active View: " + viewCollector.ToElementIds().Count)
Dim docCollector As New FilteredElementCollector(uiDoc.Document)
docCollector.OfCategory(BuiltInCategory.OST_Walls)
message.AppendLine("Wall category elements within document: " + docCollector.ToElementIds().Count)
TaskDialog.Show("Revit", message.ToString())
End Sub
CopyVB.NET
Public Shared Sub GetScheduleContents(viewSchedule As ViewSchedule)
Dim typeCollector As New FilteredElementCollector(viewSchedule.Document, viewSchedule.Id)
typeCollector.WhereElementIsElementType()
Dim numberOfTypes As Integer = typeCollector.Count()
Dim instCollector As New FilteredElementCollector(viewSchedule.Document, viewSchedule.Id)
instCollector.WhereElementIsNotElementType()
Dim numberOfInstances As Integer = instCollector.Count()
TaskDialog.Show("Elements in schedule", [String].Format("Types {0} instances {1}", numberOfTypes, numberOfInstances))
End Sub
Exceptions
See Also