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
for i in layer:
if str(i) == "red" :
elif str(i) == "yellow":
OUT = styles
Thanks for the reply. Added str but still makes no difference.
if item == “00A” : Updated.append(“00B”)
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.
Computational BIM manager, Intégrateur BIM
just realized you attached image
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.
Thanks everybody for the help!