Unit Conversion Issue

I am trying to use Python to do some unit conversions of parameter values being derived from MEP Fabrication Pipe elements. I am using the same Python code to obtain unit conversions of two different built-in parameter names, yet I am getting different results. See image and attached codes. My goal is to have the Python code being used for the Overall Size unit conversion to output like how the Outside Diameter is being outputted, in decimal feet.

First question, why are the outputs being handled differently?

Second question, what changes to the code need to be made to have the unit conversion for Overall Size be outputted as Decimal Feet?

Any help or insight would be greatly appreciated. Thank you.

#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_REFERENCE_OVERALLSIZE).AsDouble(), DisplayUnitType.DUT_DECIMAL_FEET)

OUT = x




#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_DECIMAL_FEET)

OUT = x

use AsValueString instead of AsDouble

1 Like