ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Examples of in-line variable substitution with ModelBuilder system variables

  • Using the %i% system variable with in-line variable substitution
  • Using the %n% system variable with in-line variable substitution

ModelBuilder provides two built-in system variables that can be used in iteration workflows. These two system variables contain the current iteration number and the current list index: %i% refers to the current list position in a list variable (the first position is zero), and %n% refers to the current model iteration (the first iteration is zero).

Using the %i% system variable with in-line variable substitution

For models that run a process on a list of inputs, each time the process runs, the output will have the same name as the output from the previous run of the process, and the previous output will be overwritten. To avoid overwriting previous outputs in successive iterations, append the name of the output with %i%, which will give each output a unique name that indicates its position in the list of inputs.

Using %i%

Using the %n% system variable with in-line variable substitution

%n% gives the current model iteration number and is used in an iterating model. In the example below, the For iterator is used to iterate a model four times. The output of the Buffer tool is used as feedback into the tool as input. The model iterates and creates a new output at each iteration. %n% is used in the output name of the Buffer tool to give the output of each iteration a new name.

Using %n%

Caution:

If you are using %n% in the output name of a model parameter, and the model is run from its tool dialog box in ArcMap or ArcCatalog, the iteration number of the application is substituted for %n%. Since the iteration number %n% of the application is 0, the model tool will fail after one iteration with the error message "ERROR 000622: Failed to execute (Tool). Parameters are not valid." In this case, you must either change the variable so that it is not a model parameter or remove %n% from the output name.

Related Topics

  • A quick tour of using inline variable substitution
Feedback on this topic?

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal