At ArcGIS 9.0, the script tool framework was first introduced and is geared towards creating Python-based tools for new users, but it is an inefficient process for more experienced users. In the script tool framework:
- You define parameters through the wizard
- You create validation code that lives in the toolbox
- Plus you create and maintain the source script separately
All of these parts are segregated and more difficult to manage collectively.
In ArcGIS 10.1, there are two ways to creating your own geoprocessing tools with Python: script tools in custom toolboxes and script tools in Python toolboxes .
In a Python toolbox, parameter definitions, validation code, and the source code are handled in the same place, making it easier to create and maintain Python tools. Additionally, Python toolboxes support capabilities that script tools do not, such as value tables, composite data types, and custom license checking.
For those with Python experience, Python toolboxes provide the opportunity to take advantage of your Python skills and create tools entirely and easily out of Python. If you are new to Python, you will be better suited to creating tools in custom toolboxes, where the wizard will step you through the necessary parts of a script tool.
If you use or are planning to use significant validation code in your script tool, almost certainly you will find the experience more straightforward in a Python toolbox.
|Custom toolboxes||Python toolboxes|
Script tools in a custom toolbox are organized into three parts:
A Python toolbox is a Python script with a .pyt extension, which contains all aspects of a toolbox and its tools: parameters, validation, and execution. This is done using Python classes: one class for the toolbox and one class for each of the tools.
The source code can be edited in any editor.
The parameters are edited through the script tool wizard.
Validation code (if used) can be edited via the wizard in an editor.
Python toolbox files (.pyt) can be edited in any editor, and all parts of the tool (parameter definitions, validation code, and source code) can be edited in the same place.
As Python toolboxes can only be edited in an editor, they do not support copying/pasting within a toolbox or between toolboxes.
Using other tools
Custom toolboxes support various tool types, including Python script tools, model tools (built with ModelBuilder), and built-in tools (built using ArcObjects and a compiled language like .NET).
Python toolboxes do not directly support other tool types; that is, you cannot add model or built-in tools to your Python toolbox. However, you can call tools in other toolboxes from within the Python toolbox code.
Python toolboxes support an isLicensed method which allows you to control whether a tool can be opened based on your criteria.
Script tools in a custom toolbox can have their source code embedded into the toolbox and locked with a password.