Remove extra Digits

By converting it into a string, Dynamo adds me some extra digits.

Can I remove them in Dynamo or in Revit?

You can use the split node to split the string by , for example. Or you can use the string remove node

1 Like

How does that look like?

Hello
2 methods (Package Crumple + remove )

cordially
christian.stan

There’s a node in the Data-Shapes package names “Number to Rounded String”

1 Like

Where is the Solution without Digits?

0 for incoming for Crumple String.rounding node at digits level

and 6 instead of 4 in the code block for the remove solution

Cordially
christian.stan

1 Like

The simplistic Python :snake: explanation.

1 Like

Or like this :slight_smile:

3 Likes

You can use the Number.ToString node from Springs or do it in a Python node in different ways(I prefer the one below):

3 Likes

Use some magic with regex, if 1,23545 is input or 1,323443dadwa :slight_smile:

input = IN[0]
import re
OUT = re.sub(r',.*', '', input)

With input is 1.3565 or 1.4343dadawdwa

input = IN[0]
import re
re.sub(r'\..*', '', input)
5 Likes

For information, rstrip method can accept multiple characters as argument

5 Likes

You can also fix this by just converting the number to an integer. Math.Floor (or Ceiling) will work. This happens when the number is a double and the string includes the trailing zeroes.

8 Likes

:heart_eyes: Love the options everyone :+1:

2 Likes

Hello
base on your idea


cordially
christian.stan

I didn’t know that, but it would still make a 20.000 into a 2, wouldn’t it?

1 Like

Correct, thats why i would just use python’s round() function and turn that into a string.

good catch, I didn’t consider this case, so it doesn’t work

Thank you!!!