LearnRevitAPI

Jan 2, 2023

Convert Units

Revit API uses feet as its internal units regardless of the unit system used in the project. So whenever we work in a project with metric units, it still stores all the values in feet.

How to Convert Units?

If you work with metric units, then this will help you. Every time you get or set values, you need to work in feet. 

Some people just divide or multiply values with approx. number to convert. But this causes differences later on because of rounding error. 

There will be situations when this difference will be on the edge, where rounding goes up or down. You can easily lose a few m² on a project with 10 000 rooms. 

I would suggest to use Revit API native tools for conversion, so there are no differences in your results.

UnitUtils Class

Revit API has a class UnitUtils that has useful conversion methods:
ConvertFromInternalUnits and
ConvertToInternalUnits

Both functions have the same arguments. We need a value and units. 


They are both easy to work with. However, there was a change introduced in Revit 2021, that has replaced a class to get units:

DisplayUnitType -> UnitTypeId

value = 10.0

units = UnitTypeId.Meters # UnitTypeId.Centimeters... Check RevitAPIDocs for more

value_m = UnitUtils.ConvertFromInternalUnits(value, units)   # 10.0 feet   -> Meters
value_ft = UnitUtils.ConvertToInternalUnits(value, units)    # 10.0 meters -> Feet

I hope you find it useful and use in your scripts.

Enjoyed Newsletter?

Leave a Testimonial Here.

⌨️ Happy Coding!
Erik Frits

Join Newsletter

📩 You will be added to Revit API Newsletter

Join Us!

which is already read by 6800+ people!

Last Chance To Claim LIFETIME ACCESS. (Only ~50 Seats Left)