Value

摘要

在脚本工具的 ToolValidator 类中使用时,会从 GetParameterInfo 中返回 Value 对象,该对象也可通过 GetParameter 函数返回,具体取决于参数类型。

属性

属性说明数据类型
isEmpty
(只读)

指定值对象是否为空。

注:

如果参数没有值,则参数的 value 属性将返回 NoneTypeisEmpty 属性将无法访问。 要确定某个参数是否具有值,请使用 if 语句检查 Parameter value 属性,例如 if param.value:

Boolean
value
(可读写)

值对象的值。

String

代码示例

Value 示例

updateParameters 方法根据 NetCDF 文件的属性名称填充第二个参数的值列表。

def updateParameters(self):
    """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parameter
    has been changed."""

    # If the parameter has been altered, but not validated
    if self.params[0].altered and not self.params[0].hasBeenValidated:
        # Create a NetCDFFIleProperties object based on the input and
        #   use it to populate the value list of the second parameter.
        net_cdf = arcpy.NetCDFFileProperties(self.params[0].value.value)
        att_names = net_cdf.getAttributeNames()
        self.params[1].filter.list = att_names
        self.params[1].value = att_names[0]

    return

相关主题