Family Class


An element that represents a custom family (not a system family) in Autodesk Revit.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)

Syntax

C#
public class Family : Element
Visual Basic
Public Class Family _
	Inherits Element
Visual C++
public ref class Family : public Element

Remarks

Custom families within the Revit API represented by three objects - Family, FamilySymbol and FamilyInstance . Each object plays a significant part in the structure of families. The Family element represents the entire family that consists of a collection of types, such as an 'I Beam'. You can think of that object as representing the entire family file. The Family object contains a number of FamilySymbol elements. The FamilySymbol object represents a specific set of family settings within that Family and represents what is known in the Revit user interface as a Type, such as 'W14x32'. The FamilyInstance object represents an actual instance of that type placed the Autodesk Revit project. For example the FamilyInstance would be a single instance of a W14x32 column within the project.

Examples

Copy C#
public void GetInfoForSymbols(Family family)
{
    StringBuilder message = new StringBuilder("Selected element's family name is : " + family.Name);
    ISet<ElementId> familySymbolIds = family.GetFamilySymbolIds();

    if (familySymbolIds.Count == 0)
    {
        message.AppendLine("Contains no family symbols.");
    }
    else
    {
        message.AppendLine("The family symbols contained in this family are : ");

        // Get family symbols which is contained in this family
        foreach (ElementId id in familySymbolIds)
        {
            FamilySymbol familySymbol = family.Document.GetElement(id) as FamilySymbol;
            // Get family symbol name
            message.AppendLine("\nName: " + familySymbol.Name);
            foreach (ElementId materialId in familySymbol.GetMaterialIds(false))
            {
                Material material = familySymbol.Document.GetElement(materialId) as Material;
                message.AppendLine("\nMaterial : " + material.Name);
            }
        }
    }

    TaskDialog.Show("Revit",message.ToString());
}
Copy VB.NET
Public Sub GetInfoForSymbols(family As Family)
    Dim message As New StringBuilder("Selected element's family name is : " & Convert.ToString(family.Name))
    Dim familySymbolIds As ISet(Of ElementId) = family.GetFamilySymbolIds()

    If familySymbolIds.Count = 0 Then
        message.AppendLine("Contains no family symbols.")
    Else
        message.AppendLine("The family symbols contained in this family are : ")

        ' Get family symbols which is contained in this family
        For Each id As ElementId In familySymbolIds
            Dim familySymbol As FamilySymbol = TryCast(family.Document.GetElement(id), FamilySymbol)
            ' Get family symbol name
            message.AppendLine(vbLf & "Name: " + familySymbol.Name)
            For Each materialId As ElementId In familySymbol.GetMaterialIds(False)
                Dim material As Material = TryCast(familySymbol.Document.GetElement(materialId), Material)
                message.AppendLine(vbLf & "Material : " + material.Name)
            Next
        Next
    End If

    TaskDialog.Show("Revit", message.ToString())
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB Element
Autodesk.Revit.DB Family

See Also