Community Tip - You can change your system assigned username to something more personal in your community settings. X
No question but a tip.
I want to have the dimensions of a bush in the parameter Subtitle
If a dimension is rounds to zero, then I don't want that zero in the Parameter subtitle.
Example:
di = 0.8
L = 2.5
D = 4
RTOS defaults to rounding to 1 decimal (RTOS is available from Creo 11 and higher)
If I would do it that way then it would be
SUBTITLE = \
"d" + RTOS(Di)+\
" L" + RTOS(L)+\
" D" + RTOS(D)Which would result in Subtitle == d0.8 L2.5 D4.0
If I would type RTOS(D,0) then it would be "D4"
With that knowledge I made an equation for how much decimals I need.
Ceil(D - Floor (D))In this case if D = 4,2 it would be 4,2-4 which is 0,2 and it is then rounded up to 1
If D = 4,0 then it would be 4,0 - 4 which is 0 and it is then rounded op to 0
So then you get
SUBTITLE = \
"d" + RTOS(Di,Ceil(Di - Floor (Di))) +\
" L" + RTOS(L,Ceil(L - Floor (L)))+\
" D" + RTOS(D,Ceil(D - Floor (D)))Which would result in Subtitle == d0.8 L2.5 D4
But we are not there yet, because in edge cases where you have two decimals which are rounded down to 0 or rounded up to 1, it still goes wrong.
If D is 4.01 the string for D would be 4.0
So I used Floor on the values but added 0.05 so it would behave like a normal Round
SUBTITLE = \
"d" + RTOS(Di,Ceil(Floor(Di+0.05,1) - Floor (Di+0.05))) +\
" L" + RTOS(L,Ceil(Floor(L+0.05,1) - Floor (L+0.05) )) +\
" D" + RTOS(D,Ceil(Floor(D+0.05,1) - Floor (D+0.05) )) In this case even if D = 3.99 or 4.01, it would result in Subtitle == d0.8 L2.5 D4
I hope this helps people.
And maybe someone has a version that is even better.
