Converting Units in Python

Hi guys,

I try to get some Revit parameter value but it returns in API Units (imperial). How can I convert value from Revit’s internal units (imperial) to document units (active Revit document units) in RIR Python?

Hi @mucahitbgoker,

Built in Rhino.Inside.Revit components convert from Revit model units (feet) to Rhino model units every time it gets a parameter value. This way all the values you have on Grasshopper are on the same units no mater where come from.

To convert to Rhino units you can do the following:

import clr
from RhinoInside.Revit.Convert.Geometry import UnitConverter
from Rhino import RhinoDoc

revit_value = element.LookupParameter(name).AsDouble()
value = UnitConverter.ConvertFromHostUnits(revit_value, RhinoDoc.ActiveDoc.ModelUnitSystem)
1 Like

@kike I am unable to import UnitConverter from the RhinoInside.Revit.Convert.Geometry has the location of that method changed?

Hi Alpha, See these methods in the docs.

1 Like