ModelBuilder detects which processes in your model must run first so that dependent processes have the data needed to run successfully. This happens automatically as you make connections using the output of one tool as the input to another tool. However, occasionally you may need to control the order of operations between two related but disconnected processes. In such cases, preconditions can be used to control the order of operations. A process can be made to run after another process by making the output of the first process a precondition to the second process. Any variable can be made a precondition to running the tool, and any tool can have more than one precondition. If a tool has more than one precondition, all the preconditions must return True in order for the tool to run.
Set a precondition
In this example, two separate but related processes will be connected using a precondition so that one process runs before the other. The first string of processes creates a new feature dataset within a new file geodatabase. The second process clips a feature class to a study area and writes the output to the newly created feature dataset.
If the model above is run as-is, there is no way to control the order of operations. The Clip tool may run before its output location is even created, resulting in an error.
In the model below, the Output Feature Dataset variable must be made a precondition to the Clip tool. By doing this, the Clip tool will run after Create Feature Dataset and the Output Feature Dataset has been created.
To make a variable a precondition of a tool, use one of the following techniques:
- Click the variable and drag to draw a precondition connector line from the variable to the tool.
- Open the tool by double-clicking, or right-clicking and clicking Open. Click the Properties tab, and click the Precondition drop-down arrow to select the variable. You can add multiple preconditions, if necessary. When you click OK, a precondition connector line appears between the variable and tool.