FamilyInstance Class


his object represents a single instance of a family type, such as a single I beam.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 18.0.0.0 (18.0.0.420)

Syntax

C#
public class FamilyInstance : Instance
Visual Basic
Public Class FamilyInstance _
	Inherits Instance
Visual C++
public ref class FamilyInstance : public Instance

Remarks

Examples of FamilyInstance objects within Autodesk Revit are Beams, Columns, Braces and Desks. The FamilyInstance object provides more detailed properties that enable the type of the family instance to be changed, thus changing their appearance within the project.

Examples

Copy C#
public void GetInfo_FamilyInstance(FamilyInstance familyInstance)
{
    string message = "FamilyInstance : ";
    // Get FamilyInstance AnalyticalModel type
    if (null != familyInstance.GetAnalyticalModel())
    {
        message += "\nFamilyInstance AnalyticalModel is : " + familyInstance.GetAnalyticalModel();
    }

    // Get FamilyInstance host name
    if (familyInstance.Host != null)
    {
        message += "\nFamilyInstance host name is : " + familyInstance.Host.Name;
    }

    foreach (ElementId materialId in familyInstance.GetMaterialIds(false))
    {
        Material material = familyInstance.Document.GetElement(materialId) as Material;
        message += "\nFamilyInstance e material : " + material.Name;
    }
    // Get FamilyInstance room name
    if (familyInstance.Room != null)
    {
        message += "\nFamilyInstance room name is : " + familyInstance.Room.Name;
    }

    // Get FamilyInstance structural type
    message += "\nFamilyInstance structural type is : " + familyInstance.StructuralType;

    // Get FamilyInstance structural usage
    message += "\nFamilyInstance structural usage is : " + familyInstance.StructuralUsage;

    TaskDialog.Show("Revit",message);
}
Copy VB.NET
Public Sub GetInfo_FamilyInstance(familyInstance As FamilyInstance)
    Dim message As String = "FamilyInstance : "
    ' Get FamilyInstance AnalyticalModel type
    If familyInstance.GetAnalyticalModel() IsNot Nothing Then
        message += vbLf & "FamilyInstance AnalyticalModel is : " & familyInstance.GetAnalyticalModel().ToString()
    End If

    ' Get FamilyInstance host name
    If familyInstance.Host IsNot Nothing Then
        message += vbLf & "FamilyInstance host name is : " & Convert.ToString(familyInstance.Host.Name)
    End If

    For Each materialId As ElementId In familyInstance.GetMaterialIds(False)
        Dim material As Material = TryCast(familyInstance.Document.GetElement(materialId), Material)
        message += vbLf & "FamilyInstance e material : " + material.Name
    Next
    ' Get FamilyInstance room name
    If familyInstance.Room IsNot Nothing Then
        message += vbLf & "FamilyInstance room name is : " & Convert.ToString(familyInstance.Room.Name)
    End If

    ' Get FamilyInstance structural type
    message += vbLf & "FamilyInstance structural type is : " & Convert.ToString(familyInstance.StructuralType)

    ' Get FamilyInstance structural usage
    message += vbLf & "FamilyInstance structural usage is : " & Convert.ToString(familyInstance.StructuralUsage)

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

Inheritance Hierarchy

See Also