Methods for distributing tools
The simplest method for sharing tools is to send a copy (via e-mail, for example) of your custom toolbox (.tbx) containing your tools. This method only works if your tools do not use any other resources such as datasets, map layers in a map document, layer files, or external script files or libraries—that is, your tools are like system tools, relying on nothing more than data your user provides in tool parameters. Tools that don't need any resources are referred to as generic tools.
The more common case is that your tools are not generic and rely on other resources to run. In this case, you have two methods for distributing your tools:
- ZIP and share—You consolidate all the resources your tool needs into a folder, package the folder using standard ZIP compression utility to create a zip (.zip) file , then share the .zip file via e-mail or by uploading it to the Model and Script tool gallery on the geoprocessing resource center.
- Publish to ArcGIS Server—ArcGIS Server allows you to share services across an enterprise (intranet) and across the Web (Internet). Services include toolboxes and maps.
ZIP and share a well-organized system folder
You start by gathering your toolboxes and tool data into one well-organized system folder, the ToolShare folder. The illustrations below show the ToolShare structure. The content and structure of the ToolShare folder is just a suggestion—you can use any folder structure you like. The ToolShare folder structure is recommended if you are going to upload your tools to the Model and Script tool gallery found on the geoprocessing resource center.
Once you have gathered together your toolbox and the resources it needs, you create a .zip file of the folder. To create a .zip file in Windows:
- Right-click the folder and click Send To > Compressed (zipped) Folder. Using the above illustration as an example, you would right-click the Thiessens folder.
- Send the .zip file (via e-mail, for example). The reciepient (your user) opens the .zip file and copies the contents to their local machine.
Map and layer packages
Map and layer packages were introduced in ArcGIS 10. You can package maps and layers within ArcMap or by using tools in the Packaging Toolset. Map and layer packages you create can be shared on ArcGIS online. ArcGIS 10 does not have the capability to package toolboxes in the same way you package maps and layers.
After you have gathered the resources your tool needs, and before you create the .zip file, there are a number of issues you have to address.
Any data that your tools use must be located in the ToolShare folder or its subfolders. In the ToolShare folder structure illustrated above, the data would be placed in the ToolData folder and every tool would have the Store relative path names (instead of absolute paths) option checked.
If you are sharing a map document (.mxd), all data used in the map must be in the same folder as the map document. You can either copy the data yourself and ensure that the option to Store relative pathnames to data sources is checked, or use the Consolidate Map tool.
Intermediate and scratch data
Your models and scripts will most likely need a location to write intermediate and scratch data. This location will be a folder or geodatabase on your user's local disk. Typically, you want your user to set their scratch workspace environment and use this environment setting as the location to write intermediate and scratch data.
The person who recieves your tools may not have the necessary products or licenses to execute your tools. Even if the recipient has the necessary extension installed, they may not have obtained a license to use that extension in their current session. If they don't have a license, the tool will exit with an error message indicating that the extension is not enabled, and they will have to obtain a license by clicking Extensions in the Customize menu of their current application, such as ArcCatalog or ArcMap, and enabling the required extension.
If the necessary extension is not installed, the tool might not appear in the toolbox.
You should, of course, document which extensions are required and take steps to ensure that the user knows what extensions are required. These steps may not suffice for some users. A particularly bad scenario is when all the tools in your toolbox depend on an uninstalled extension and, as noted above, nothing appears when the user opens the toolbox. One solution is to provide a script tool within the delivered toolbox that checks for the necessary extensions and outputs messages if there are problems. Such a tool doesn't depend on any extension and will always be loaded into the toolbox. The user can then run this extension-checking tool and view informative messages.
Any script you want to share should have logic to check the proper licenses and product levels.
You can embed your script in your toolbox. By embedding your script, you don't have a separate script file that needs to be shared.
However, if your Python scripts import modules that you've authored, or you do not embed your scripts in the toolbox, you need to ensure that these scripts and modules are in the ToolShare folder.
System tools can always be found on any system with ArcGIS installed. You do not have to copy system tools into your custom toolbox, or add a system toolbox to a script (using arcpy.AddToolbox()).
Publishing to ArcGIS Server
ArcGIS Server allows you to share services across an enterprise (intranet) and across the Web (Internet). Services include toolboxes and maps. The main advantages of sharing your GIS resources with ArcGIS Server are the same as sharing any data through any kind of server technology—for instance, the data is centrally managed, supports multiple users, and provides clients with the most up-to-date information. Another advantage, particularly for geoprocessing, is that tools execute on the server computer, using the resources (such as licenses) found on the server computer.