Update Version Python conditional not working


I’m trying to do a very simple script with python to update sheet versions.

I copied the python code from Mostafa here How to write simple "if elif else" conditional in Python

The idea is to update the letter to the next one, so 00A would be 00B and so on. But the python script, no matter what, always returns the else condition. Can anybody help please? The more I check it the less I can think about a reason it’s not working.


It’s needed to convert the data with the String From Object node before feeding the Python scrip!

You can try this:

layer = IN[0]
for i in layer:
	if str(i) == "red" :
	elif str(i)  == "yellow":
		styles.append ("0.18mm")
	else :
		styles.append ("0.13mm")

OUT = styles

Thanks for the reply. Added str but still makes no difference.

if item == “00A” : Updated.append(“00B”)

Changed to
if str(item) == “00A” : Updated.append(“00B”)

Did you try entering the value of the parameter instead of its name into the python node?

I think you should slice your item in list to get only last 2-3 letters before input in the Python node.

The if, else, is "== " ?! that means exactly the equal. Is not the case in your list.

Yien Chao
Computational BIM manager, Intégrateur BIM
et photographe

just realized you attached image :smiley:
this will work

Well, actually it works when inputting data from the code block…so the problem is that the list provided by the Parameter.ParameterByName node is not in the right format.

Solved by converting the data to string before feeding the Python scrip with the node String from Object.

Oh my… :roll_eyes:

Thanks everybody for the help!