What is a script tool?
Creating a script tool allows you to turn your own Python scripts and functionality into your own geoprocessing tools—tools that look and act like system geoprocessing tools. Once created, a script tool provides many advantages:
- A script tool that you create is an integral part of geoprocessing, just like a system tool—you can open it from the Search or Catalog window, use it in ModelBuilder and the Python window, and call it from another script.
- You can write messages to the Results window and progress dialog box.
- Using built-in documentation tools, you can provide documentation.
- When the script is run as a script tool, arcpy is fully aware of the application (such as ArcMap) it was called from. Settings made in the application, such as arcpy.env.overwriteOutput and arcpy.env.scratchWorkspace, are available from ArcPy in your script tool.
To create a script tool in a custom toolbox, you need three things:
- A script
- A custom toolbox
- A precise definition of the parameters of your script
Creating the toolbox
A custom toolbox can be created by right-clicking the folder or geodatabase in which you want to create the new toolbox, then click New > Toolbox.
Creating script tools in a toolbox
To create a script tool, right-click your toolbox, and click Add > Script. This opens the Add Script wizard which takes you step by step through the process of creating a script tool. After completing the steps, your toolbox will contain a new script tool. You can always modify the properties names and data types of this script tool by right-clicking the script tool and choosing Properties.
To learn more about adding a script tool, see Adding a script tool.