def set_unit(val): '''display given value with the conversion variables on top ''' val_out = None try: val_out = UnitUtils.Convert(val, USER_UNIT_IN, USER_UNIT_OUT) except: val_out = val return val_out
def convert_cm_to_feet(length): """Function to convert cm to feet.""" rvt_year = int(app.VersionNumber) # RVT >= 2022 if rvt_year < 2022: from Autodesk.Revit.DB import DisplayUnitType return UnitUtils.Convert(length, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET) # RVT >= 2022 else: from Autodesk.Revit.DB import UnitTypeId return UnitUtils.ConvertToInternalUnits(length, UnitTypeId.Centimeters)