Convert length parameter to number value


#1

Yes, there is another topic that started off with this question. However they side-stepped the issue.

I would like to create a simple system to convert a Length parameter to its decimal-feet value number.
i.e [Height: 25’ - 0"] becomes [25.0]

This specific scenario: I have a set of RCP trees. I am trying to generate lollipop tree models at these places for a rendering thing. I have managed to get the height of these RCP Trees. However it outputs at “25’ - 0”. I want the Trunk Height to match the existing tree and the canopy ball to be 2/3 of the height. Where it all falls apart is the math part. Dynamo can’t do math on a length type parameters. It returns null each time. My initial thought for a work around was “Just take the first two digits and then string-to-number them.” Problem is some of the trees are only 6’ so that won’t work, and work-arounds are bad. I want a way to just convert 25’ - 0" to 25.0. I feel like there has to be a simple way to do this.

Yes I know Height for Trunk Height is spelled Hight. That’s a house keeping issue for another time.

Revit.Revit RCP Tree to Lollipop Partial Code.dyn (417.9 KB)

Tree Sandbox.rvt (888 KB)


#2

Share an rvt with the families in question.


#3

Updated the post with a sandbox model.


#4

Thanks. Hard to recreate the issue without this.


#6

Posted a copy of that part of the script. It’s a little different than the picture, but effectively the same code.


#7

Found the Solution. The Node “Parameter.Value” Will return the parameter as the correct value.
Gotta love those 1 node solutions.


#8

You probably should just be using GetParameterValueByName in the first place, instead of ParameterByName.


#9

Agreed - this will be much faster and direct. No need for finding the parameter, just get the value directly. :slight_smile: