Round values to whole numbers in text
So I'm building a project that I want to be fully scalable for the user, and want to display the final output size on a flat surface.
I got this working by making a textbox and adding ""X" ~ toString(#BED_X/mm) ~ "mm"" and this displays the variable as it should.
However, if I scale the project by anything other than 50mm increments, it changes from "xxx mm" to "xxx.xxxxxxxxxxxxxx mm"
Ive chased around my assembly and parts, and theres nothing I can find that would add that value.
Is there a way for me to just round the number in the textbox to not have decimals?
This is my issue
If I set my frame size to a 50mm increment number, it works just fine
Answers
-
You can use the round() function to round your numbers. Or you may need to use the roundToPrecision() function if you need a specific number of decimals. However, your units will be in meters, since Onshape uses Meters behind the scenes. It is possible to convert them with a multiplier constant, but it may simply be easiest to use a custom feature to help.
Here is a custom feature I made to specifically convert variables to string and specify units and rounding:
Convert to String: https://cad.onshape.com/documents/19dacc01596e7c326bbfb137/w/0567dd7ffac5327836c9bb93/e/cd2c8c…
▚▞▚▞▚▞▚▞▚0 -
Thank you so much! That's exactly what I needed.
0


