Is there a built in API method to format a length value into a desired unit system

for example if file unitsystem is feet, it will format 26 into 2’ 2", and 26.125 into 2’ 2-1/8" and also take into consideration the accuracy in the file setting, and if the unitsystem is m, it will format 26.125 into 26 m instead if the accuracy is higher.

I couldn’t find anything in rhinoscript and inside rhinocommon, the Rhino.LengthValue class seems promising but after some test doesn’t seem to do what I’m looking for.

I’m looking for a built in function like this to help me write a simple script to create a text dot on a point and show it’s measured z height in a desired unit system and accuracy above a user input base plane. I think it’s not impossible to manually code that formatting, but I’m wondering if Rhino has something useful already.

Hi @Jun_Wang,

Try using Localization.FormatNumber.

– Dale

Thank you Dale, this looks like exactly what I’m looking for!

Since precision is a int, can I assume it will take a int from 0-7 since there is a built in 8 levels of precision in the unit setting menu?

Precision is just the number of decimal places…

– Dale

When it comes to fraction?