If Then Else in model builder

Discussion created by dan_h_b on Aug 14, 2013
Latest reply on May 30, 2014 by afenix
Hi all,
I have a model which iterates through feature classes in a geodatabase (image attached)
For each feature class, it runs the check Geometry tool.
I then use the "Get Count" tool to count the number of rows in the output table.
I then want to add an expression where if the number of rows is greater than 0 it should keep running the rest of the model, otherwise it should go on to the next feature class.

I thought this could be achieved by using the Calculate Value tool using the following code.

CountMe(%Row Count%)

Code Block
def CountMe(n):
 import arcpy
 if n > 0:
  return "true"
  return "false"

Where %Row Count% is the output from the "Get Count" tool.

This returns True and False values, and I have the output from this set as a precondition to the next steps in the model.

However, I assumed that only "true" data would go through, but all the data seems to go through i.e. the model will push through an empty table from the Check Geometry tool all the way to the end.

I've had a read online and I think that using the Calculate Value tool is the wrong way to go about this.  Am I right in assuming that what I need is a python script that will give me 2 outputs (True and False) and then I can connect the "True" as a precondition to the rest of the model, and leave the "False" disconnected, so the model stops and the iterator goes on to the next feature class?

If so, would anybody be able to give me some help with this?

Many thanks