Using Lists

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:

Steps:
  1. Right-click the variable.
  2. Click Properties.
  3. Click A list of values as shown in the illustration below:
    Creating List variable

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 of using a list variable

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.

List example

The model is now ready to run from within ModelBuilder. The model will execute for each input contained in the Input Feature Class list variable.

Using in-line variable substitution and 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. %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 illustration below:

Steps:
  1. Double-click and open the Clip tool dialog box.
  2. Fill in the Input Features and the Clip Features.
  3. In Output Feature Class, click the first cell, define the path of the output, and use %i% in the name as shown in the illustration above.
  4. 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 illustration.
  5. This fills all the cells with the same path location and name of the file as shown by number 3 in the illustration above. Using the %i% systems variable as the in-line variable ensures that each output will have a unique name with the list number of the data in the variable appended at the end of the output name. The outputs will be named Out0, Out1, Out2, and so on.

9/13/2011