# Units in dynamo and python

**URL:** <https://forum.dynamobim.com/t/units-in-dynamo-and-python/29251>\
**Category:** Uncategorized\
**Created:** [December 4, 2018, 8:34am UTC](https://forum.dynamobim.com/t/units-in-dynamo-and-python/29251 "2018-12-04T08:34:34Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [December 4, 2018, 9:10pm UTC](https://forum.dynamobim.com/t/units-in-dynamo-and-python/29251/3 "2018-12-04T21:10:30Z")

</div>

Be aware when you obtain parameter values using python via API methods. It will return internal units if you do not convert the values:

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

From the example parameter, we can obtain the numeric value as a double or as a string representation:

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

String representation:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

pipe = UnwrapElement(IN[0])

x = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER).AsValueString()

OUT = x

```

Numeric value:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

pipe = UnwrapElement(IN[0])

x = pipe.get_Parameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER).AsDouble()

OUT = x

```

You can see from the image above, that the AsDouble value is Revit internal units (imperial) but since I am working with the metric system, I need to convert the value if I obtain the value via the API:

```
import clr

#Import the Revit API
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

pipe = UnwrapElement(IN[0])

x = UnitUtils.ConvertFromInternalUnits(pipe.get_Parameter(BuiltInParameter.RBS_PIPE_OUTER_DIAMETER).AsDouble(), DisplayUnitType.DUT_MILLIMETERS)

OUT = x
```

---

_[View the full topic](https://forum.dynamobim.com/t/units-in-dynamo-and-python/29251)._
