How get i the correct "rounding"?

hello dynos,

I want the numbers shown as in Revit.
Dynamo does hide ceros and not representing the numbers as shown.
How can i deal with that?




Math.Round(number, 3);

still it ignores ceros

I’m lost… which number isn’t displaying as you want, and where are you looking to display it?

1 Like

thats from Revit schedule

it has 3 digits! 0.000 becomes 0

Final aim is to convert them to strings an at it to the name
thats the units in Revit… Dynamo is doing it own stuff

String.FromObject after the three digit rounding should do the trick. You can then either add zeros via pad left, or take the Substring to stop at 3 digits last the decimal as needed.

1 Like

how to deal with +/- values i think i have to do some clever sorting if “-” do it in a other way

and length if it is > 9

I would recommend getting the index of the “.”, and counting 3 digits after that.

1 Like

:slight_smile: i got confused … i am in the list rollercoster

This may help:

indx = String.IndexOf(str,”.”);
frmtdStr = String.SubString(str, 0, indx+3);

Untested as I am not at my computer. If you’re still stuck when I get to it in ~30 minutes I’ll post a confirmed fix.

That sounds good… minwhile i continue

Python would probably be quicker at this point. You can round and then set the number of trailing zeros with this method.

nums = IN[0]
out = []

for num in nums:
    n = '{:.3f}'.format(round(num,2))
OUT = out

That would be almost the solution, but for any reson dynamo writes 3- insteat of -3,
i think multiply strings is not the way

You’re multiplying by a negative so you’re getting the strings backwards. You would just get the first x substrings instead, starting at index 0.

thats it looks like Revit Schedule view

I sense a speed race!

1 Like