Creating a script tool allows you to turn your 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 an ArcGIS toolbox (.atbx) file.
Starting with ArcGIS Pro 3.0, you can't create legacy toolboxes (.tbx) in a project. However, you can still add and edit existing legacy toolboxes to a project.
- ArcGIS toolbox—This toolbox format, introduced at 2.9, is stored as an .atbx file on disk. This format provides better cross-release compatibility and persistence, improved performance, and scalability.
- Legacy toolbox—This toolbox format is stored as a .tbx file on disk or within a database.
Create an ArcGIS toolbox by right-clicking Toolboxes in the Catalog pane and clicking New Toolbox (.atbx). On the New Toolbox dialog box, browse to the folder in which you want to create the 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.