GetParameterInfo

Краткая информация

Возвращает список объектов параметров для заданного инструмента и обычно используется в классе инструмента скрипта ToolValidator.

Синтаксис

GetParameterInfo (tool_name)
ПараметрОписаниеТип данных
tool_name

The tool name. Including the toolbox alias will help to resolve any conflicts with duplicate tool names.

Примечание:

When the GetParameterInfo function is used as part of a script tool's ToolValidator class, the tool_name argument is optional.

String
Возвращаемое значение
Тип данныхОписание
Parameter

Возвращает список параметров объектов.

Пример кода

Пример 1 GetParameterInfo

Отображение некоторых свойств объекта параметров для указанного инструмента.

import arcpy

# Load tool parameter objects into list.
params = arcpy.GetParameterInfo("HotSpots")

for param in params:
    print("Name: {}, Type: {}, Value: {}".format(
        param.name, param.parameterType, param.value))
Пример 2 GetParameterInfo

Настройка символов для выходного набора данных инструмента скрипта.

import os
import arcpy

# Set data variables for Clip tool.
in_features = arcpy.GetParameterAsText(0)
clip_features = arcpy.GetParameterAsText(1)
out_feature_class = arcpy.GetParameterAsText(2)

# Execute Clip tool
output = arcpy.analysis.Clip(in_features, clip_features,
                             out_feature_class)[0]

# Get parameter objects
params = arcpy.GetParameterInfo()

# Use describe on result object and get shape type.
desc = arcpy.Describe(output)

# Set symbology property for out_feature_class parameter
# Layer files are located in same folder as the .py file
lyr_location = os.path.dirname(__file__)

if desc.shapeType == "Polygon":
    params[2].symbology = os.path.join(lyr_location, "Polygon.lyr")
elif desc.shapeType == "Polyline":
    params[2].symbology = os.path.join(lyr_location, "Polyline.lyr")
else:
    params[2].symbology = os.path.join(lyr_location, "Point.lyr")

Связанные разделы