Clockwork Math.Round+


Noticed that while using the Math.Round+ node from Clockwork that it drops some "0"s at the end if they are the last number in the whole rounded decimal numbers.

I am looking into having all numbers using the same number of decimal cases. Any idea on how to do this?

Thank you

Can you ensure that your “object.type” is either doubles or numbers and not strings? :slight_smile: Use the “object.type” node to verify this.

All doubles. Yes.

The last “0” is unimportant as it does not have an impact on the number therefore it is not shown in a double, in a string you could have it patted in later on if you’re writing it to e.g. excel etc.

Having dbl-clicked the node to see what it was doing, it might be something to do with the actual math.round function itself, not the clockwork node.

Some insights in this thread, but I cannot get the python script to work on mine.

That is not what is adressed in that topic…

There is really nothing wrong with the result as the number “-7837.15” and “-7837.150” is in fact the same and the last 0 is not shown as a result of that…

Yes. I agree. The result is not wrong, it is just not showing the last 0. But because I want to push the values to text parameters in Revit they will just not look right, visually, I mean.

I was thinking about a workaround like:

  • convert to string
  • split at “.”
  • get length to the right of the “.”
  • if length < 3, pad right with a 0

not very elegant…

Number is converted to strings additional “0”'s will be added automatically (i believe it is 6 digests)

1 Like

Nice. That is helpful.

If a comment solved your problem please mark it as the solution and help people discover the solution faster in the future. :slight_smile:

Actually, I cannot implement that idea.
The Revit parameters I need to SetParameter need to be doubles or numbers. Does not accept text.

i was almost there…

I take it back.
I can convert the strings back into doubles using archi-labs ToDouble node.
I just need to do right before the SetParameter node.

Thank you for your help @Jonathan.Olesen

actually…if I convert them back I loose the just added trailing 0.

I just removed the solution from the thread because it only works if the targed parameter is of a text type.

That is how “numbers” and “doubles” work in the realm of Revit, Dynamo and Python :wink: You cannot have unnecessary padding unless working with text

And just if you’re tempted to attempt the same with Python you’ll face the same “problem” or inability to force unnecessary zero’es