Show Navigation | Hide Navigation
You are here:
Geoprocessing > Automating your work with scripts > Accessing tools within a geoprocessing script

Complex parameters

Release 9.3
Last modified June 3, 2010
E-mail This Topic Printable Version Give Us Feedback

Print all topics in : "Accessing tools within a geoprocessing script"


Related Topics

Note: This topic was updated for 9.3.1.

Tool parameters are usually defined using simple text strings. Dataset names, paths, keywords, field names, tolerances, and domain names are all simple to specify using a quoted string.

Some parameters are harder to define, as they define a more complex parameter type that requires many properties. Instead of using long, complicated text strings to define these parameters, they are defined using objects (for example, spatial references, value tables, and field maps) that have all the required information defined as read/write properties. The documentation for each tool contains a scripting example of how each tool parameter is defined and used.
Parameter objects are created using the geoprocessor's CreateObject method. Once an object has been created, its properties must be set before it is used as a parameter. An object's properties are read or set in the same manner as geoprocessing environment settings.

In the following code example, the CreateFeatureClass tool is executed using a spatial reference object for its optional Coordinate System parameter. The spatial reference object is created using the CreateObject method and its information is loaded from a projection file using the spatial reference object's CreateFromFile method.

import arcgisscripting
gp = arcgisscripting.create(9.3)

inputWorkspace = "c:/temp"
outputName =  "rivers.shp"

# Create a spatial reference object
#
spatialRef = gp.CreateObject("spatialreference")

# Use a projection file to define the spatial reference's properties
#
spatialRef.CreateFromFile(r"c:\program files\arcgis\Coordinate Systems\" +                             "Projected Coordinate Systems\Continental\North America\North America Equidistant Conic.prj")

# Run CreateFeatureClass using the spatial reference object
#
gp.CreateFeatureClass(inputWorkspace, outputName, "POLYLINE", "", "", "", spatialRef)


Learn more about the CreateObject method
Learn more about using value tables
Learn more about the SpatialReference object
Learn more about field mappings

Please visit the Feedback page to comment or give suggestions on ArcGIS Desktop Help.
Copyright © Environmental Systems Research Institute, Inc.