Converting decimal feet to fractional feet and inches


#1

Hello all,

new user here and I was wondering if I could get some help on a particular issue.

I am trying to have dynamo convert a decimal feet number to fraction feet and inches. the converted dimension should be formatted like xx’-yy". the idea is to then push this “converted” dimension back into Revit. also i need to have the precision of the “converted” dimension set at the nearest 1/2".

for example, I need to go from
4.56’ to 4’-6 3/4" (need to keep the “dash” as part of the dimension)

I did a search but have had no luck and unfortunately my programming skills are severely lacking.

any help would be appreciated.


#2

You could try something like rounding your number to the nearest 1/2" (in decimal format) first. Then convert the decimal to inches, round that down to an integer, take the difference, and convert that to fractional inches.

Springs has a node that already does this to the nearest inch. You could use that as a guide as well.


#3

Hi, I just made a custom node to do it, it should work but you might get a string as an output, I’m not expert in imperial numbers.

Round is at 1/4, but can easily fixed at 1/2, I was not sure what you needed.

FractionalInchesConverter.dyn (2.2 KB)


#4

@vincitygialam Here a better version, where you can pick your denominator (1/2, 1/4, 1/8…). Is it what you needed?

FractionalInchesConverter.dyn (18.0 KB)