SetDefaultFamilyTypeId Method


Sets the default family type id for the given family category.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Since:  2015

Syntax

C#
public void SetDefaultFamilyTypeId(
	ElementId familyCategoryId,
	ElementId familyTypeId
)
Visual Basic
Public Sub SetDefaultFamilyTypeId ( _
	familyCategoryId As ElementId, _
	familyTypeId As ElementId _
)
Visual C++
public:
void SetDefaultFamilyTypeId(
	ElementId^ familyCategoryId, 
	ElementId^ familyTypeId
)

Parameters

familyCategoryId
Type: Autodesk.Revit.DBElementId
The family category id.
familyTypeId
Type: Autodesk.Revit.DBElementId
The default family type id.

Examples

CopyC#
private void SetDefaultTypeFromDoor(Document document, FamilyInstance door)
{
    ElementId doorCategoryId = new ElementId(BuiltInCategory.OST_Doors);

    // It is necessary to test the type suitability to be a default family type, for not every type can be set as default. 
    // Trying to set a non-qualifying default type will cause an exception
    if (door.Symbol.IsValidDefaultFamilyType(doorCategoryId))
    {
        document.SetDefaultFamilyTypeId(doorCategoryId, door.Symbol.Id);
    }
}
CopyVB.NET
Private Sub SetDefaultTypeFromDoor(document As Document, door As FamilyInstance)
   Dim doorCategoryId As New ElementId(BuiltInCategory.OST_Doors)

   ' It is necessary to test the type suitability to be a default family type, for not every type can be set as default. 
   ' Trying to set a non-qualifying default type will cause an exception
   If door.Symbol.IsValidDefaultFamilyType(doorCategoryId) Then
      document.SetDefaultFamilyTypeId(doorCategoryId, door.Symbol.Id)
   End If
End Sub

Exceptions

ExceptionCondition
Autodesk.Revit.ExceptionsArgumentException The family type id familyTypeId is invalid for the give family category familyCategoryId.
Autodesk.Revit.ExceptionsArgumentNullException A non-optional argument was null

See Also

ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →