Tuesday, July 26, 2016

Programming: Module 10

This week's lab required me to create a toolbox and script to share for another user.  Standalone scripts are great tools, but creating a script tool has even more benefits.  Script tools are easy to share, a user doesn't need to know how to use Python, and it includes a dialog box.

The screenshot below shows the results of the script tool window that is created through this lab.  To do this, I added a toolbox to my Module 10 folder.  I then added a script to the tool box and made sure "Store relative path names" was checked.  I selected an already created script foe the Script File.  Next, I added four parameters to the script tool.  I adjusted the data type and properties and set the input and output file location.  When I open the tool, the window below opens.

Tool Options
The next step in the lab was to adjust the parameters in the standalone script.  I replaced the filenames and file paths with arcpy.GetParameter().  The parameters correspond to the order I added int he script properties.  In order to run the script without an error, I had to add str() to the output folder.  Then I ran the tool with the clip boundary of Durango.shp and selected the four input features.  To print statements in the dialog box, I had to adjust the standalone script again.  I changed the print command to arcpy.AddMessage().  Results are below.

Dialog Box
To share the script, I compressed the toolbox and the standalone script.
Flowchart



No comments:

Post a Comment