SetParameter

Zusammenfassung

Sets a specified parameter property by index or parameter name using an object. This function is used to pass objects from a script to a script tool. If you need to pass a string, use the SetParameterAsText function.

Syntax

SetParameter (index, value)
ParameterErläuterungDatentyp
index

The specified parameter's index position or parameter name.

Integer
value

The object that will set the specified parameter's property.

Object

Codebeispiel

SetParameter example

Pass an object to a specified tool parameter by index.

import arcpy

# Get the input feature class name.
fc = arcpy.GetParameterAsText(0)

# Obtain the spatial reference object and return it to the tool.
spatial_ref = arcpy.Describe(fc).spatialReference
arcpy.SetParameter(1, spatial_ref)
SetParameter example

Pass an object to a specified tool parameter by parameter name.

import arcpy

# Get the input feature class name.
fc = arcpy.GetParameterAsText("in_features")

# Obtain the spatial reference object and return it to the tool.
spatial_ref = arcpy.Describe(fc).spatialReference
arcpy.SetParameter("out_spatial_reference", spatial_ref)

Verwandte Themen