Revit lbf/ft Default Unit? LookupParameter().AsDouble() Returning Unexpected Results

I’ve been doing some work with the Revit API through the Python node to schedule some parameter values, and in this case steel tonnage. I’ve opted to use Python instead of vanilla Dynamo since I need to be able to get a parameter value regardless of whether it’s an instance or type parameter (as well as some other reasons). I am working mostly with models which I didn’t author myself, so simple solutions such as adding my own parameter won’t work. The particular problem I’m having is being able to calculate tonnage given a beam’s length and weight (in lb/ft). Most steel members have their weight as a type parameter called “W”, which is a number, however one particular family instead uses a “Nominal Weight” parameter, expressed in lbf/ft.

To get the parameter’s value, I am using the following method:

element.LookupParameter(“Nominal Weight”).AsDouble()

I understand that the AsDouble() method gets the parameter’s value as a double in its default unit of measure, which is to say that if I am working with a model that has meters as its default unit of measure for length, the AsDouble() method would still return the length in feet.

The nominal weight for this HSS tube is 10.7 lbf/ft, which is what shows up using only Dynamo, but Python instead returns a value of 156.1547614. Does anyone know a good method to get a value which matches what is being displayed in the type properties? A workaround might be to use the AsString() method, split the result by a space character and cast the first value as a float, but this might not be reliable for other parameters.

Everything inside Revit is handled as Imperial units… this is an issue well described in the forum.

Try to see here how to solve it.

Thanks for the reference. I understand that Revit internally deals with Imperial units, but since lbf/ft is already an imperial unit and it wasn’t matching the extracted parameter value, there must have been something else going on. It looks like although the display unit type of this parameter is DUT_POUNDS_FORCE_PER_FOOT, it is stored internally as some other unit, but converts correctly to DUT_POUNDS_FORCE_FEET (yielding the desired 10.7 lbf).

Thanks again


import clr
clr.AddReference(“RevitAPI”)
from Autodesk.Revit.DB import *

parameterName = “Nominal Weight”
dut = DisplayUnitType.DUT_POUND_FORCE_FEET
parameter = element.LookupParameter(parameterName)
weight = parameter.AsDouble()
if str(parameter.DisplayUnitType) == “DUT_POUNDS_FORCE_PER_FOOT”:
weight = UnitUtils.ConvertFromInternalUnits(weight, dut)

You are right… it is some kind of messy :slight_smile:
maybe this can help you further

The parameter’s unit type is also stored in the parameter element. In Dynamo 2.0, the conversion of MEP values should already be done automatically. If you’re on an earlier version, I’ve got a utility node in springs that will help you get the value visible in the UI:

Very interesting, I’ll be sure to crack it open to see the inner workings. The automatic conversion in Dynamo 2.0 is very convenient, but I’m working almost exclusively in python for ease of complicated data manipulation, so the springs node will definitely help clarify some of the back-end workflow.

Thanks again, for the help, guys.