Examples of inline model variable substitution with environment settings
Any geoprocessing environment setting can be exposed as a model variable and used for inline variable substitution. For more information about how geoprocessing environments are used in ModelBuilder, see A quick tour of managing model environments.
Geoprocessing environment settings can be set in ModelBuilder from the process properties page.
Setting environments through process properties
In this example, the Scratch Workspace environment setting is set, using the process properties page Environments tab, and used for inline variable substitution in a model.
- Choose a tool in a model, right-click, then click Properties.
- On the Environments tab, check the Workspace option.
- Click Values.
- Define the path of the scratch workspace.
- Click OK to get back to the model.
- Use %scratchworkspace% as an inline substitute for the output path parameter. When the tool runs, %scratchworkspace% is substituted with the value you entered for the scratch workspace environment.
Substituting environment settings in model parameters
If you are using an environment for inline substitution (such as scratchWorkspace or XYResolution) in a model variable, and the model variable is exposed as a model parameter, the application level settings for the environment will override any model level environment settings.
For example, in the model below:
- the scratch workspace environment has been set to C:\Scratch\Scratch.gdb in the model and
- the scratch workspace for the current ArcMap document is set to C:\Temp\Temp.gdb.
The Output Copy variable in the model uses %scratchworkspace% in the output path (%scratchworkspace%\Output_Copy). When the model is run within ModelBuilder, the results will be written to C:\Scratch\Scratch.gdb.
If this model is run from its dialog,%scratchworkspace% is replaced with the scratch workspace set at the application level (C:\Temp\Temp.gdb) and the output is written to C:\Temp\Temp.gdb.
For cases such as the example model, where a model parameter is substituting an environment:
- Avoid making variables using inline environment substitution (such as scratchWorkspace) a model parameter. This will ensure that the model level environment is used at the run time.
- Alternatively, do not set the environment at the model level and rely only on the application level environment setting