Trying to get Feet to fraction node (steamnodes) to read in inches instead of feet

Hi all,

I am attempting to run a script in which dynamo will auto populate the “comment” section of my element within revit with certain parameters. One of the parameters I am trying to grab is a fraction that deals in inches (ex.1/2") When I plug this into dynamo it returns a decimal that I want to convert back to its original fraction form however when I use the feet to fraction node it is reading the parameter as if it was in feet and returns me 0’ -6". How do I get this to read in inches instead? Thanks (in the example I have attached I’ve just plugged in a number node of .5 to show an example, I understand that .5 is also half a foot however the parameters that I have my script running through all specify inches. Capture

Test if the string g starts with 0”-, and of so, replace 0”- with ””

Have you tried dividing the input by 12?

1 Like

What if the value to be returned was 5 3/8” though?

exactly my issue, we deal with fractions of all kinds, not always ones that are divisible by 12

The springs node sometimes has issues which can be resolved via formatting or rounding slightly in advance, but I used to utilize an edit of the code similar to this in order to minimize upstream edits.

@Dimitar_Venkov feel free to use this to tweak any future springs updates (or more likely let me know why you see it failing so I can learn from you yet again - :slight_smile:).

So there are unit formatting utilities available in Revit API and you can do something like this:

I am guessing that’s not what you want. Just so that we are on the same page, let me explain how this component works. When I feed in Units.GetInternal it uses whatever settings you have set for the project do format the units. So in this case I have Fractional Feet and Inches.

Obviously changing that is not always possible hence another approach where you don’t use the internal units, and instead make a new dummy unit setup just for the formatting exercise:

Now we are getting somewhere. Basically we create a new Units object, but set it to Fractional Inches so when we format our value from 0.5 it will format it to inches only instead of feet and inches.

Hope this makes sense.

Now I would have published this to a package manager but the package manager has been a little broken. I am talking to Autodesk as I am writing this, and they promised a fix soon. When that happens i will publish this, and you can get them by downloading the latest archi-lab.net package.

Ps. Code is available from here: https://github.com/ksobon/archilab Also sample file is there as well under _dynamoSamples.
Ps2. cc @Zach_Kron let me know when the issue with Package Manager has been fixed so that I can post the update. There are two different people waiting on that update now. Thanks!

3 Likes

Awesome! Thanks Konrad, I will be looking at implementing this tomorrow once I get in the office and will reply with my findings

Thank you Jacob, with your and Konrads help I should be able to get to the bottom of this. Cheers

I’m not sure if you understood me. If you know for a fact that some value is in inches only, you can just divide it by 12 and still run it through the feet fraction node. For Example:

In the image above we get 0.5 as 1/2 " when true and as 6" when false.

I’m pretty sure it’s not perfect, so you could try Jacob’s fixed code as well in the mean time. I like Konrad’s approach of using the much more robust tool already available in Revit but we’ll see how long it will take for the package manager to be fixed…

2 Likes