How to use converter, correctly?

Hello,

i want to convert units to internal units:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application


def convert_cm_to_internal(length):
	rvt_year = int(app.VersionNumber)
	if rvt_year < 2022:
		from Autodesk.Revit.DB import DisplayUnitType
		return UnitUtils.Convert(length, DisplayUnitType.DUT_CENTIMETERS, DisplayUnitType.DUT_DECIMAL_FEET)
	else:
		from Autodesk.Revit.DB import UnitTypeId
		return UnitUtils.ConvertToInternalUnits(length,UnitTypeId,Centimeters)


OUT = convert_cm_to_internal(IN[0])

where is my error ? :wink:

KR

Andreas

Syntexerror

UnitTypeId.Centermeters #the dot was missing!
2 Likes