# Units conversion Revit 2022

**URL:** <https://forum.dynamobim.com/t/units-conversion-revit-2022/67831>\
**Category:** Revit\
**Tags:** revit, python, dynamo\
**Created:** [September 3, 2021, 9:44am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831 "2021-09-03T09:44:52Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![krzysztof.nowakFWCRN](https://avatars.discourse-cdn.com/v4/letter/k/76d3ee/32.png) [@krzysztof.nowakFWCRN](https://forum.dynamobim.com/u/krzysztof.nowakFWCRN)\
**Post date:** [September 3, 2021, 9:44am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/1 "2021-09-03T09:44:52Z")

</div>

Hi,  
I have a problem with the conversion of units in revit 2022. In revit 18.3 (i know its old - i`m new in dynamo :/ ) i`m using expression like this:  
"

```auto
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import DisplayUnitType, UnitUtils

# output unit
dut = DisplayUnitType.DUT_CENTIMETERS

OUT = UnitUtils.ConvertToInternalUnits(IN[0], dut)

```

";

but in revit 2022 there is some warnings:

 ![Revit_CxPHMKfyMh](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d3a197b9720bb8a86ed50e099de2a58c0b8ae326.png)

“Ostrzeżenie:IronPythonEvaluator.EvaluateIronPythonScript operacja nie powiodła się.  
Traceback (most recent call last):  
File “”, line 4, in   
ImportError: Cannot import name DisplayUnitType”

I have to convert units to centimeters to get surrounding elements for doors (like concrete beams), tolerance is 5 cm.

I know “DisplayUnitType Property Resource Not Available for the Active API Year” (2022), but maybe someone had the same problem and find solution.

Have a nice day!

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 3, 2021, 11:54am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/2 "2021-09-03T11:54:16Z")

</div>

See if this gets you headed in the right direction.

> [@Getting wrong stairs length/width from Python & Revit API](https://forum.dynamobim.com/t/getting-wrong-stairs-length-width-from-python-revit-api/67176/6):
>
> Here is an example using Revit 2022, but the import should be the same. import clr clr.AddReference('RevitAPI') from Autodesk.Revit.DB import \* OUT = UnitUtils.Convert(11.7,UnitTypeId.Feet,UnitTypeId.Millimeters) Keep in mind too that in R2021 the DisplayUnitType was depreciated, and then in R2022 is it replaced by the SpecTypeId, ForgeTypeId and UnitTypeId classes.

---

<div class="post-metadata">

**Author:** ![krzysztof.nowakFWCRN](https://avatars.discourse-cdn.com/v4/letter/k/76d3ee/32.png) [@krzysztof.nowakFWCRN](https://forum.dynamobim.com/u/krzysztof.nowakFWCRN)\
**Post date:** [September 7, 2021, 9:18am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/3 "2021-09-07T09:18:11Z")

</div>

Thx SeanP, but its not working for me 😕

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/4/d/4df37344da60bedcc13f556b911a7f50368f039c.png)

I tried to rewrite the script but it still gets an error at the end.

Does anyone know conversion node which can work in this case

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 7, 2021, 9:26am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/4 "2021-09-07T09:26:34Z")

</div>

Try UnitTypeId.Milimeters in place of DusplayUnit.METRIC.

---

<div class="post-metadata">

**Author:** ![krzysztof.nowakFWCRN](https://avatars.discourse-cdn.com/v4/letter/k/76d3ee/32.png) [@krzysztof.nowakFWCRN](https://forum.dynamobim.com/u/krzysztof.nowakFWCRN)\
**Post date:** [September 7, 2021, 9:39am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/5 "2021-09-07T09:39:47Z")

</div>

Nope 😕

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/6/e6108d2345679dcc232cac51f10e2097aece8c47.png)

---

<div class="post-metadata">

**Author:** ![krzysztof.nowakFWCRN](https://avatars.discourse-cdn.com/v4/letter/k/76d3ee/32.png) [@krzysztof.nowakFWCRN](https://forum.dynamobim.com/u/krzysztof.nowakFWCRN)\
**Post date:** [September 7, 2021, 9:41am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/6 "2021-09-07T09:41:57Z")

</div>

I tried too:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/a/5/a5f688594ec6e6f334320902f645278f0ee210b7.png)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 7, 2021, 9:42am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/7 "2021-09-07T09:42:14Z")

</div>

Here is the API reference.

[https://www.revitapidocs.com/2022/b5e8d065-d274-62f8-7b5d-89722f7c44f3.htm](https://www.revitapidocs.com/2022/b5e8d065-d274-62f8-7b5d-89722f7c44f3.htm)

It would help if I could spell.

Millimeters with 2 “LL”…

Or Meter or CM

![Screenshot_20210907-044736](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/a/daaa4e44a5f2b53a25fffff3b20e3092f219a2ca.png)

---

<div class="post-metadata">

**Author:** ![SeanP](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/seanp/32/42560_2.png) [@SeanP](https://forum.dynamobim.com/u/SeanP)\
**Post date:** [September 7, 2021, 10:46am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/8 "2021-09-07T10:46:22Z")

</div>

Try this.

```auto
"
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

utid = UnitTypeId.MetersCentimeters

OUT = UnitUtils.ConvertToInternalUnits(IN[0],utid)
";

```

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/5/d/5d142be3dc79643fe53d9b3be7dccbbf5e09f83a.png)

---

<div class="post-metadata">

**Author:** ![MartinSpence](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/martinspence/32/25208_2.png) [@MartinSpence](https://forum.dynamobim.com/u/MartinSpence)\
**Post date:** [September 7, 2021, 10:56am UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/9 "2021-09-07T10:56:06Z")

</div>

Haha, was just messing around with this, and the ForgeTypeId. Got way more complex then the actual answer 🙂

That being said though, I think the OP needs the Convert **From** 🙂

```auto
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import UnitUtils, UnitTypeId

wallType = UnwrapElement(IN[0])

widthInternal = wallType.Width

#output unit
uid = UnitTypeId.Millimeters

OUT = UnitUtils.ConvertFromInternalUnits(widthInternal, uid)

```

Image for context 🙂

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/7/e73b77b6e81af74d5b09d3c24f881ceb1b3a96cd.png)

---

<div class="post-metadata">

**Author:** ![krzysztof.nowakFWCRN](https://avatars.discourse-cdn.com/v4/letter/k/76d3ee/32.png) [@krzysztof.nowakFWCRN](https://forum.dynamobim.com/u/krzysztof.nowakFWCRN)\
**Post date:** [September 9, 2021, 1:34pm UTC](https://forum.dynamobim.com/t/units-conversion-revit-2022/67831/10 "2021-09-09T13:34:10Z")

</div>

Hi, thank You for help!

Script works well with code like that:

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/6/b62573f039f267c92a2b8830a95e881c2245a384.png)

I have to learn a lot 🙂 🙂 🙂
