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
Create the toolbox
You can create a custom toolbox by right-clicking Toolboxes in the Catalog pane and clicking New Toolbox. On the Select Toolbox dialog box, browse to the folder or geodatabase in which you want to create the new toolbox, enter a new name, and click Save.
Create script tools in a toolbox
To create a script tool, right-click your toolbox and click New > Script. This opens a dialog box that 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 Add a script tool.