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
I hope you find it useful and use in your scripts.
Join Newsletter
📩 You will be added to Revit API Newsletter
Join Us!
which is already read by 7400+ people!
◼️BLACK FRIDAY DEAL 20% OFF. Ends in: