SetDefaultFamilyTypeId Method


Document Set Default Family Type Id Method

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

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public void SetDefaultFamilyTypeId(
	ElementId familyCategoryId,
	ElementId familyTypeId
)

Parameters

familyCategoryId ElementId
The family category id.
familyTypeId ElementId
The default family type id.
Exceptions
Exception Condition
ArgumentException The family type id familyTypeId is invalid for the give family category familyCategoryId.
ArgumentNullException A non-optional argument was null
Example
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);
    }
}
See Also