Select to view content in your preferred language

Testing for selection in ModelBuilder

1176
4
Jump to solution
07-10-2014 01:35 PM
ChrisBruce
Regular Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
4 Replies
DanPatterson_Retired
MVP Emeritus
ChrisBruce
Regular Contributor

Looks like just what I need. I'll give it a try and report back.

0 Kudos
FreddieGibson
Honored Contributor

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.

ChrisBruce
Regular Contributor

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.

0 Kudos