I'm working on a model that will create different buffers for different selections. So I'm using Make Feature Layer and adding an expression to select a subset of features and then using the buffer tool on that subset. But there may be times when a selection doesn't return any features, in which case I wouldn't want to run the buffer. Is there a way in ModelBuilder to test whether or not any features are selected and only run the subsequent step if there are?
Alternatively I could export to a Python script and handle this testing there but I'm not quite sure how to accomplish this in Python either.
Solved! Go to Solution.
Try GetCount as shown in the help files http://resources.arcgis.com/en/help/main/10.2/index.html#//0017000000n7000000
Try GetCount as shown in the help files http://resources.arcgis.com/en/help/main/10.2/index.html#//0017000000n7000000
Looks like just what I need. I'll give it a try and report back.
Another thing you can look at is the Using If-Then-Else logic for branching page in the desktop help. You could use this in addition to the Get Count tool to handle how to proceed with the model based on the selected number of features.
Thanks for the excellent advice! GetCount is working like I need it to and I may well end up using the If-Then-Else logic before I'm done because I'll ultimately need to add some more complexity to this model.
At first it wasn't totally clear to me how to use GetCount but I found that I just needed to connect the output from that tool to the buffer tool as a precondition and that's it. If GetCount returns 0 then the precondition is false and the subsequent tool doens't execute.