I'm trying to use Calculate Value in Modelbuilder's Arcmap to run a process if one of two booleans preconditions is true. So if both of precondintion are false the process shouldn't run, otherwise it should run. First I used the following python code:
Expression: pergunta("%parameter1%","%parameter2%")
Code Block: def pergunta(par1,par2):
import arcpy
if par1 == "false" and par2=="false":
return "false"
This returned false every time, even when it was supposed to be true. So I changed the code block for the following:
def pergunta(par1,par2):
import arcpy
if par1 == "false" and par2=="false":
return "false"
else:
return "true"
In this case it returned true every time, even when it supposed to be false.
My last attempt for the code block was the following:
def pergunta(par1,par2):
import arcpy
if par1 == "false" and par2=="false":
return "false"
elif par1 == "true" and par2=="false":
return "true"
elif par1 == "false" and par2=="true":
return "true"
elif par1 == "true" and par2=="true":
return "true"
Once again, it returned false every time, even when it was supposed to be true.
It seems like no matter what I do, it is not considering if the preconditions are false or true. What am I doing wrong?
elif
statements could be replaced with a singleelse: return True
. I expect theif
fails due to incorrect type. Of course all of this is basic Python programming.