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 Catalog pane, use it in ModelBuilder and the Python window, and call it from another script.
- You can write messages to the Geoprocessing history and tool 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 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 Toolboxes in the Catalog pane, then New Toolbox. In the Select Toolbox dialog box, browse to the folder or geodatabase in which you want to create the new toolbox, then enter a new name, and Save.
Creating script tools in a toolbox
To create a script tool, right-click your toolbox, and click New > Script Tool. This opens a dialog which allows you to step through the process of creating a script tool. After completing the steps, your toolbox will contain a new script tool. You can make changes to a script tool by right-clicking the tool and choosing Properties.
To learn more about adding a script tool, see Adding a script tool.