Probably there is a simple solution but does anybody know of a quick method to convert a number to string without the comma and the extra trailing zeros?
theres a number to rounded string node, i believe in the data shapes package
Trying to not use packages but thanks for the suggestion
If I recall correctly the comma is used instead
of a decimal point due to the way your windows environment is configured. If you never want a comma, change those and you’ll get the decimal, but it will be a decimal everywhere (i.e. calculator, excel, etc.). If you do t want that, use a String.Replace node to replace the two.
For the trailing zeros, do you want to stop at a particular point, or just cull the trailing values after the decimal?
I was trying to avoid that but i think i have no other option
Had the same issue last week. Dynamo detects the number as a double and not int.
You should convert the number to an int using python and then convert it to string.
Likely you are a few builds behind them, as int to string conversion has been addressed to not include the trailing zeros. Doubles have the issue persist in some cases though.
Hi,
Here’s some Python code for a list of numbers.
python script
import sys
nums=IN[0]
def numtotext(n):
te=str(n)
lte=[c for c in te]
while lte[-1]=="0":
lte.pop(-1)
if lte[-1]==".":
lte.pop(-1)
tem=""
for i in lte:
tem=tem+i
return tem
OUT = [numtotext(n) for n in nums]
edit:
I had forgotten an obvious value (int)
python script 2:
import sys
nums=IN[0]
def numtotext(n):
te=str(n)
if not "." in te:
return te
else:
lte=[c for c in te]
while lte[-1]=="0":
lte.pop(-1)
if lte[-1]==".":
lte.pop(-1)
tem=""
for i in lte:
tem=tem+i
return tem
OUT = [numtotext(n) for n in nums]
cordially
christian.stan
You have the latest version for Revit 2024; as of this post there are six versions of Dynamo since that build including a major update in Dynamo 3.0.0, and five minor updates since then in 3.1, 3.2, 3.3, 3.4 and 3.5.
You’re basically 2 years behind in Dynamo just like you’re 2 years behind in Revit.
That said I am not sure if the round function returns an int or double even in the latest builds. If not it likely can be resolved faster than the Python option (as you won’t have to spin up a Python instance) with a single like of design script: value: int = Math.Round(n);
.
Not at the PC, but this is a result of attempting to return a list as a single integer. Try to change it to: value: int[] = Math.Round(n);
which should work for a list