Is This Content Helpful?
We're glad to know this article was helpful.
Instructions provided describe how to call a custom model from Python and run it as a Windows scheduled task.
Another method for automating the geoprocessing tasks contained in a custom model is to export the model to a script. However, it is suggested that there is some knowledge of the scripting language, as some edits may need to be made to the exported script.
While the geoprocessing environment of ArcGIS 9.x supports Python, VBScript, JScript, and Perl scripting languages, any scripting language that is COM compliant can be used to create successful geoprocessing scripts.
While tracing through the script below, there are a number of important things to note.
· The desktop license to be used must be retrieved by the script and available at the time when the script will be executed.
The code example below uses two models: one called 'NoParameterTool' and one called 'ParameterTool'. Both models reside in a toolbox called 'MyToolbox'.
'NoParameterTool' had all of the arguments supplied when building the model and does not need any additional information from the user at run-time.
'ParameterTool' has two arguments that must be supplied at run-time: an input shapefile and an output shapefile.
# Import system modules...
import arcgisscripting, sys, string, os
# Create the Geoprocessor object...
gp = arcgisscripting.create()
# Set the License...
# Not required if the model does not use any extension tools
# Load environment settings if necessary...
gp.LoadSettings = "c:/temp/mysettings.xml"
# Load required toolboxes...
gp.OverwriteOutput = 1
# All arguments were supplied to model prior to saving
# Two arguments are supplied at run-time