Last modified June 3, 2010
Print all topics in : "Accessing tools within a geoprocessing script"
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)