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
clr.AddReference('RhinoInside.Revit')
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