Units in dynamo and python

hello brothers , i need to ask does dynamo has separate units than those set in revit ? Also if i write python code in dynamo , will it have different units that i have to set then.

Dynamo is unitless. It’s all based on Revit units.

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

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

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
9 Likes