A variable that contains one or more values is called a list variable. You can declare one or more variables in a model as a list variable. To make a variable a list, do the following:
- Right-click the variable.
- Click Properties.
The Input Properties dialog box appears.
- On the General tab, under This variable contains, click A list of values.
Opening the list variable will display the batch grid where you enter the values for the variable. Once the list variable is connected to a tool, that tool and all downstream processes (the processes that depend on the output of the tool) will execute once for each value in the list. Using list variables is equivalent to using batch, except that you don't have to provide values for other single-value variables in your model. Using list variables requires that you be familiar with using the batch grid.
Example
The example used to show list processing is a simple Clip and Buffer model as shown below.
In the example, the Input Feature variable was made a list. As a result of making Input Feature a list variable, the Output Clipped Feature and Output Buffer Feature variables are automatically made list variables because they are dependent on the Input Feature variable. In the example below, the Clip tool is opened, and three input clip feature classes have been added. The Clip Features and XY Tolerance parameters are unavailable for all cells except the first cell. This is because the Study Area Clip variable is not a list, and there is no variable for the XY Tolerance parameter. The value of the first cell will be used for all three inputs.
The model is now ready to run in ModelBuilder. The model will execute for each input contained in the Input Feature class list variable.
Using in-line variable substitution and the fill option with lists
When an output list variable is created in a model, you can use %i% as in-line variable substitution in the output name. Using %i% appends the list number at the end of output name. If you have many inputs, it can get tedious to define a unique output name for each output in a batch grid; instead, you can use the fill option and in-line variable substitution together as shown in the image below:
- Double-click and open the Clip tool dialog box.
- Fill in the Input Features and Clip Features parameters.
- In Output Feature Class, click the first cell, define the path of the output, and use %i% in the name as shown in the image above.
- After you define the path and name of the first cell, right-click in the cell and click Fill as shown by number 2 in the image.