SetParameter
Краткая информация
Настраивает свойство заданного параметра по индексу или имени параметра с помощью объекта. Эта функция используется при передаче объектов из скрипта в инструмент скрипта. Если необходима передача строки, используйте функцию SetParameterAsText.
Синтаксис
SetParameter(index, value)
| Параметр | Объяснение | Тип данных |
|---|---|---|
|
index |
The specified parameter's index position or parameter name. |
Integer |
|
value |
The object that will set the specified parameter's property. |
Object |
Пример кода
Пример настройки параметра
Передать объект указанному параметру инструмента по индексу.
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)
Пример настройки параметра
Передать объект указанному параметру инструмента по имени параметра.
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)