HOW TO
In some cases, it is required to input user-created interactive features when running a model using Feature Sets. The issue is that often the creator of the model wishes to restrict the user from inputting more than the required number of minimum or maximum inputs.
This solution does not impede the user from selecting more than required minimum or maximum inputs by an error pop-up or warning, but runs the model without an output.
In an example scenario, the user already has a model using Feature Sets in their model that Appends a school feature class (Existing Schools) by adding locations using the interactive capabilities of Feature Sets (New School Locations), the model creator wishes to restrict to model user from inputting more than two points at a time.
Below is the completed model - this uses example data as a scenario, all that is needed is the Get Count and Calculate Value part.
Since Feature Set (as it is an input to a tool) is already part of the model being modified:
Expression:
countRows("%rowcount%")
Code Block (optional):
def countRows(RowCount): import arcpy if %RowCount% == 2: # feature restriction number return "true" else: return "false"
In short, this code looks at the output of the Get Count tool (the rows added to the in-memory table; if you add one feature it's 1 row, two features, 2 rows, and so on). For our scenario, we use the value to two so that when the model user clicks two new school locations, the tool creates two features in the in-memory table. (this may be different as your environment/model parameters/etc may have different requirements. This model uses point features and you may be using line features.)
When run, the tool only works if there are two points selected. Otherwise, the tool provides an informative message saying: "The process did not execute because the precondition is false."
The false precondition is created in that the Calculate Value tool's IF statement was not met, meaning an input of other than two selections.
The model runs as Completed, regardless of whether the user selects the desired amount of inputs or not, because the Calculate Value tool outputs a Boolean value, which is just true or false.
Get help from ArcGIS experts
Download the Esri Support App