Hi! Can anyone see where I should change if I want the first decimal number to appear if it is greater than 0? It is a script that displays the text in a Wall tag.

string.Split(â.â) => FirstItem
Thanks for the answer @Deniz_Maral! Hmm, I donât really know where to put those parts? Iâve just started experimenting with the program so Iâm trying it out. But as you can see in the picture, I seem to be wrong with the placement as it doesnât do what I want.
Maybe like this?
Hope that helps,
Mark
Edit :
I find nodes a bit clunky for text manipulation, so I tend to jump to pythonâŚ
Thanks for the answer @Mark.Ackerley!
I havenât worked with Phyton at all except that I pasted scripts that others have done. But I guess I can write the Phyton script in Dynamo like I did in the picture? Also donât know where in Dynamo I should put Phyton?
Hey,
Python is relatively âhuman readableââŚ
For num in IN[0]⌠so if you plug your list of numbers into IN[0], python will start looping through that listâŚ
It will round(num to 1 dp), and convert to a STRing.
then If rounded_num ends with .0, it will make num an Integer (ie. no decimals) and then make it a STRing, and add to the output list.
Else, it will add rounded_num to the output list.
Hope that helps,
Mark
Sorry Iâm a bit slow to keep up with the program. A little unsure which string is âList of numbersâ. Does it look right in the picture?
The output from your âlist no 1â is a (list of) StringsâŚ
Dynamo is very concerned about Data Types, and if it gets a String where it was expecting a Number, it will get confused.
I would hover over the yellow triangle and read the warning, it probably says âunexpected typeâ or similarâŚ
If you head back up your graph to before you converted text to strings, you could use the code there?
It would probably be easier if you included more of your graph for us to see
and included the warningsâŚ
Hope that helps,
Mark
So, yes, I think the python node wants to go hereâŚ
So it is taking numbers in and giving a list of strings out⌠You shouldnât need a bunch of nodes to the right of the python then. Just work your way across, left to right, seeing what the nodes are doingâŚ
I tried to put the script in there but as you can see in the picture I got ânullâ, then looked through the nodes on the right but think that they looks like it is needed. Still tried to remove them because to test but didnât turn out well.
Can I put a directive in the Python script that is already in the file? as you can see in the picture it finds all 3 decimal places but it has changed 10.500 (as in Revit) to 10.000
Sends the script in case anyone sees what needs to be changed/added
import clr
import sys
pyt_path = râC:\Program Files (x86)\IronPython 2.7\Libâ
sys.path.append(pyt_path)
from decimal import Decimal
def tolist(input):
if isinstance(input,list):
return input
else:
return [input]
nums = tolist(IN[0])
if IN[1] != 0 :
OUT = [str(round(Decimal(n),IN[1])) for n in nums]
else:
OUT = [str(int(round(Decimal(n),IN[1]))) for n in nums]
you have a typo⌠the python tells you⌠rounded not rounden, you donât want to just ditch something because of a warning, just work your way through methodically, understand what each part is doing and youâll get there ![]()
Thank you so much @Mark.Ackerley ! So grateful that you and the rest of you have taken the time to help me. I almost thought about giving up before the last question since I got it so well described but didnât get it right. I have dyslexia and am bad at English so even though I went through the script so many times, I didnât see the little carelessness.
Again, thank you very much! Wish you the best











