Hi, I’m trying to make a script that lets a user select pipe network parts and filters for things named inlets. It will then put information about those inlets into a table. I have that all working but for some reason I can’t get the numbers to round properly.
For some reason, despite rounding, it’s keeping the extra 0’s on the end of each number. When I look at the Math.Round node, they look correct, but when put into a table they output with the 0’s.
I searched around and found some advice that converting the integer/double into a string can fix it, I tried that but it’s still having issues. Below is what the output looks like:
I attached the script (Very unorganized, and a WIP, apologies!), but the file I’m testing in is unfortunately too big to attach (large-ish pipe network), I can try to make it smaller if someone needs. Thanks for any help!
PipeStructureTableCreator.dyn (50.7 KB)
1 Like
Please remember to search for similar topics before posting new ones. This question comes up a lot and has been answered many times already.
If your table requires string values then look into trimming them after converting. If the table does not require string values then just provide them as doubles.
When numbers are converted to strings, there are always 6 decimals. It is not clear why, and it doesn’t respect any unit setting. When you round a number first, the number is supplemented with zeros.
There are ways to work around this, like stripping zeros or cutting off a few digits, but it is not recommended because a future Dynamo version might work different.
You can use the String.GetDoubleAsString node from The Civil Nodes. This node rounds to the drawing units or the value you prefer.
This package also contains nodes to create Tables in a more easy way. It is not necessary to convert the numbers, unless you want to overrule the drawing settings for units.
3 Likes
Perfect, I hadn’t seen that Civil Nodes node mentioned anywhere else, thanks a ton!
1 Like