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.

Steps:
  1. Choose a tool in a model, right-click, then click Properties.
  2. On the Environments tab, check the Workspace option.
  3. Click Values.
  4. Define the path of the scratch workspace.
  5. Click OK to get back to the model.
  6. 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.
Using environmental setting as inline variable

Substituting environment settings in model parameters

CautionCaution:

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 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.

Model using scratch workspace in a model

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.

Model using scratch workspace in background

TipTip:

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

Related Topics


9/13/2011