Adding a script tool

  1. Right-click the toolbox or toolset in which you want to create the script tool, then click Add > Script. The illustration below shows the first panel of the Add Script dialog box.
    Add Script Wizard panel 1
    1. Enter a name for the script tool. Name is used when the script tool is run from Python. You cannot have a space in the name.
    2. Enter a label for the script tool. Label is the display name for the script tool (as shown in the Catalog window) and can contain spaces.
    3. Optionally, type a description for the script.
    4. Optionally, click the Browse button (Browse) to change the default stylesheet used for the tool. If the Stylesheet text box is empty, the default stylesheet is used.
    5. Optionally, check the Store relative path names (instead of absolute paths) check box to store relative path names.

      Only the path name to the script is stored as a relative path. Path names within the script code are not converted.

      Learn more about relative path names
    6. You can optionally uncheck Always run in foreground. If unchecked, the tool will respect the current Background Processing setting in the Geoprocessing Options dialog. If checked, the tool will always run in the foreground, overriding the Background Processing setting in the Geoprocessing Options dialog.
  2. Click Next. The wizard panel appears as follows:
    Add Script Wizard panel 2
    1. For Script File:, click the Browse button (Browse), navigate to the location of your script, then select your script.

      You can type the path name of a script file that does not exist (with the appropriate extension for the script type). The wizard will ask if you want to create the file.

      Optionally, if your script does not already exist, you can skip adding a script file and add it later by changing the properties of the script tool (right-click the tool and click Properties).

    2. Optionally, check the Show command window when executing script check box to view messages that are written to standard output. The Python print directive writes to standard output.

      Since script tools are launched from an ArcGIS application, like ArcMap and ArcCatalog, you can write messages to the progress dialog box instead of standard output.

    3. If your script is a Python script, you will want to check Run Python script in process. With this option checked, Python scripts execute faster.
  3. Click Next. The wizard panel appears as follows:
    Add Script Wizard panel 3
    1. Define the tool parameters in this panel. Almost all tools have input parameters, and all tools must have an output parameter to be used in ModelBuilder.
  4. Click Finish.

Your script tool is added to the toolbox. You can open and use it like any other geoprocessing tool. You can change any of its properties, including parameters, by right-clicking the script tool and clicking Properties.

Related Topics