Change project units

Hi !
I made a tool to change the Units of a family or project according to predefined settings.

I’m using unit.SetFormatOptions(UnitType.UT_Length, FormatOptions(DisplayUnitType.DUT_CENTIMETERS, 0.01)) to make the changes.

I cannot fin the “UT” for Distance unit in the enumeration.

Do you know if we can access this UT and change its setting ? we would like to have all the units with correct settings…

Thank you

That should get you a bit further.
Watch out for the Units deprecations depending on the version of Revit you are working with

from pyrevit import script, revit, DB, HOST_APP

output = script.get_output()

doc = revit.doc
uiapp = HOST_APP.uiapp.Application

units = doc.GetUnits()

if uiapp.VersionNumber > '2021':
    unit_types = doc.GetUnits().GetModifiableSpecs()
    # display unit types names
    for i in unit_types:

    unit_types = doc.GetUnits().GetModifiableUnitTypes()
    # display unit types names
    for i in unit_types:

Ok, so I made something that is working on 2021 but I think I need to work a little bit more for making it work on 2022


Let’s try to make a script that can adapt to revit Version