FamilyInstanceFilter Class


A filter used to find elements that are family instances of the given family symbol.

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

Syntax

C#
public class FamilyInstanceFilter : ElementSlowFilter
Visual Basic
Public Class FamilyInstanceFilter _
	Inherits ElementSlowFilter
Visual C++
public ref class FamilyInstanceFilter : public ElementSlowFilter

Remarks

This filter is a slow filter, but it uses a quick filter to eliminate non-candidate elements before the elements are obtained and expanded. Therefore this filter does not have to be paired with another quick filter to minimize the number of Elements that are expanded.

Examples

Copy C#
// Creates a FamilyInstance filter for elements that are family instances of the given family symbol in the document

// Find all family symbols whose name is "W10X49"
FilteredElementCollector collector = new FilteredElementCollector(document);
collector = collector.OfClass(typeof(FamilySymbol));

// Get Element Id for family symbol which will be used to find family instances
var query = from element in collector where element.Name == "W10X49" select element;
List<Element> famSyms = query.ToList<Element>();
ElementId symbolId = famSyms[0].Id;

// Create a FamilyInstance filter with the FamilySymbol Id
FamilyInstanceFilter filter = new FamilyInstanceFilter(document, symbolId);

// Apply the filter to the elements in the active document
collector = new FilteredElementCollector(document);
ICollection<Element> familyInstances = collector.WherePasses(filter).ToElements();
Copy VB.NET
' Creates a FamilyInstance filter for elements that are family instances of the given family symbol in the document


' Find all family symbols whose name is "W10X49"
Dim collector As New FilteredElementCollector(document)
collector = collector.OfClass(GetType(FamilySymbol))

' Get Element Id for family symbol which will be used to find family instances
Dim query As System.Collections.Generic.IEnumerable(Of Autodesk.Revit.DB.Element)
query = From element In collector _
 Where element.Name = "Level 1" _
 Select element

Dim famSyms As List(Of Element) = query.ToList()
Dim symbolId As ElementId = famSyms(0).Id

' Create a FamilyInstance filter with the FamilySymbol Id
Dim filter As New FamilyInstanceFilter(document, symbolId)

' Apply the filter to the elements in the active document
collector = New FilteredElementCollector(document)
Dim familyInstances As ICollection(Of Element) = collector.WherePasses(filter).ToElements()

Inheritance Hierarchy

See Also