I would like to use an if-else statement in my model (along the lines of this Esri blog). My model works fine (several intersects, dissolves, calculating fields, joins). However, I would like to add a check after the first process runs, which is an Intersect. If the output has 0 rows (using Get Count), the model should stop, else continue. Using the following code in the Calculate Value code code block

def countRows(rowcount):
    import arcpy
    if %rowcount% == 0:
        return false
        return true

and expression


The model runs and generates a warning

The process did no execute because the precondition is false.

It then just carries on running the other processes, all which generate the warning

All the inputs are not current.

To summarise: The input is intersected, and the rows in the output are counted. If the number of rows is 0, return false and stop. If true, carry on processing. The Calculate Value tool is set as a precondition before all the other processes can run. I've looked at the Stop-Continue tool as well, but I'm not sure how (if?) I should be using it in this instance.

edit Ran the model on an input that I knew would generate some rows after the intersect, when the Calculate Value ran and returned true, the model stopped with the error

Error 000539: Error running expression: countRows(3546) <type 'exceptions.NameError'>:
global name 'true' is not defined. Failed to execute (Calculate Value).
  • Use proper case for True/False, that should probably fix it :)
    – blah238
    Jun 19, 2012 at 7:00
  • Actually use lower-case, quoted values (strings), this is apparently what the model expects for preconditions.
    – blah238
    Jun 19, 2012 at 7:24
  • @blah238 that worked! Now the other branch of my model is failing, but I think that's because I got overexcited with my preconditions, I'll relax some of them now. Could you please add your comment as an answer so that I can accept it? Thanks! Jun 19, 2012 at 9:49
  • I have the same issue as the original question. Currently my true/false values in the calculate value tool are all-caps and when I change them to lower case and hit OK, they revert back to all caps. Anyone know why this is?
    – Steve
    Feb 12, 2014 at 17:56
  • I was able to change the true/false values to lower case but still getting "The process did no execute because the precondition is false." and "All the inputs are not current." errors. The second message comes on the export to cad tool.
    – Steve
    Feb 12, 2014 at 19:20

3 Answers 3


Use lower-case, quoted values (strings), this is apparently what the model expects for preconditions.

e.g. return "true" or return "false"


If your using 10 or above simply use the GET COUNT function in ModelBuilder and use rowCount as a precondition for your intersection.


This was both handy and detailed:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.