Set default dimension type

Hello pyRevit Friends,

I can´t find any information about setting the default types for dimensions, spot elevations, …

Is this possible with the API? A workaround would be to place and delete a dimension because this seems to set the default type.

I can not get it to work with SetDefaultFamilyTypeId:

collector = FilteredElementCollector(doc).OfClass(Autodesk.Revit.DB.DimensionType)
for symbol in collector:
    if symbol.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() == "XXX":
        new_spot_elevation_symbol = symbol
        break

dimension_category_id = ElementId(BuiltInCategory.OST_Dimensions)

doc.SetDefaultFamilyTypeId(dimension_category_id, new_spot_elevation_symbol.Id)

Exception: The family type id familyTypeId is invalid for the give family category familyCategoryId.
Parameter name: familyTypeId

Happy about any advice!
Kind regards

Hi @Gerhard.P ,

looking at the example of SetDefaultFamilyTypeId documentation, it states that

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

I suppose that if you try to

print(new_spot_elevation_symbol.IsValidDefaultFamilyType(dimension_category_id))

it will return False.

I don’t know any way to do this, I hope someone else can shed some light!

1 Like

probably something like

from pyrevit import revit
doc = revit.doc
defaultTypeId = # element type group
typeId = # element Id of the type you want to set as default
doc.SetDefaultElementTypeId(defaultTypeId, typeId)
2 Likes

I can´t believe it!

collector = FilteredElementCollector(doc).OfClass(Autodesk.Revit.DB.DimensionType)
for symbol in collector:
    if symbol.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString() == "EFP Höhe (Absolut)":
        new_spot_elevation_symbol = symbol
        break

transaction = Transaction(doc, "Change Default Type")
transaction.Start()

defaultTypeId = ElementTypeGroup.SpotElevationType
typeId = new_spot_elevation_symbol.Id

doc.SetDefaultElementTypeId(defaultTypeId, typeId)

transaction.Commit()

Works like a charm, thank you so much Jean! :smiley:

1 Like

more of a pyRevity way

from pyrevit import revit, DB   

doc = revit.doc

dim_type_group = DB.ElementTypeGroup.SpotElevationType
p = DB.BuiltInParameter.ALL_MODEL_TYPE_NAME
new_dim_type = [dt for dt in DB.FilteredElementCollector(doc).OfClass(DB.DimensionType) if dt.get_Parameter(p).AsString() == 'EFP Höhe (Absolut)'][0]

with revit.Transaction('Set default dimension type'):
    doc.SetDefaultElementTypeId(dim_type_group, new_dim_type.Id)
2 Likes