Sunday, July 26, 2015

Module 10: Custom tools

 
The ability to turn a script into a custom tool was this week's topic.  To do that, the following basic steps were followed:

1.      Create and save a .py script
2.      Create a custom toolbox for storing it
3.      Add a script tool to the custom toolbox with the AddScript wizard, selecting the saved .py script
4.      Modify the code in the script so it can receive the parameters set by the tool dialog box
5.      Set up the parameters in the tool’s properties
6.      Edit script using GetParameterAsText and GetParameter functions to set up parameter Dialog box for script tool

 
Here is a screenshot of the parameter Dialog box that allows input to the script tool.  Here there are 4 parameters, two of them already showing default locations for input and output files.  These are examples of workspace type parameters.  Two feature class parameter types are also listed: clip boundary feature and input features.  The latter was set to have a MultiValue property, since more than one .shp was used in this situation. 
 
 
 
Before the script tool ran, we edited it once more, adding AddMessages statements so that they would print in the results window, as shown below.

 
This lab was especially useful in showing how all the work of creating scripts can be used in a more simple, direct, and integrated way in ArcMap.

No comments:

Post a Comment