Model Builder Iterate and test record count

1694
1
12-16-2016 12:21 PM
ScottGarrett
New Contributor

I'm running through an intersect layer and iterator in model builder to produce many feature classes.  I'd like to test the output with a get count or script - if it has records, produce the FC, if not, do not produce the FC.  Unfortunately, the first FC it finds that does not have records stops the model - it will not move on to the next iteration.  How do I set up the model so it continues through the iterations?   Is this where a submodel comes in?

0 Kudos
1 Reply
ChrisDonohue__GISP
MVP Alum

One thing that works is to add a Get Count and then set a Precondition for the function that you want to trigger to keep it from operating if the Get Count condition is not true.  Note that this is not real obvious on how to make this work.

As an example, in this case the Model is set up to copy 5 feature classes from one Feature Dataset to another as long as the feature class contains at least one record.  So in this example, ParcelSet3 has no records (I deleted them all before running this), so was not copied.

Get Count—Help | ArcGIS for Desktop 

Another possibility would be to do some branching with For If loops in Python and then use those as to make script tools to incorporate into to your model. 

ArcGIS Help (10.2, 10.2.1, and 10.2.2) - If you are stuck at "If" - Modelbuilder

Or if you are good at Python, skip Modelbuilder and do the whole thing in Python.  As a shortcut, one can dump out the Modelbuilder stuff you already have as Python snippets to help get started.

Chris Donohue, GISP