arcgis10.2.2的python工具箱中值表类型(GPValueTable)的参数如何对其某一列(column)设置过滤器(filter)

Arcgis10.2.2版本的python工具箱
定义了一个值表类型(GPValueTable)的参数,并对值表定义了3列,均为字符串类型,想对值表设置过滤器(filter),但是提示“ValueError: FilterObject: 只能更改 ValueList 和范围过滤器的类型”,希望实现的效果是第一列的下拉选项为["2019","2020"],第二列的下拉选项["xqx2019","xqx2020"],第三列的下拉选项["tc2019',"tc2020"]
参数控件.jpg

def getParameterInfo(self):
param0 = arcpy.Parameter(
displayName="Image Time",
name="ImageTime",
datatype="GPValueTable",
parameterType="Optional",
direction="Input",
multiValue="True")

param0.columns = [["GPString", "Image Time"],
["GPString", "Image Mosaic"],
["GPString", "Image Layer"]]

param0.filter.type = "ValueList"
param6.filter.list = ["2019","2020"]

params = [param0]

return params

 
已邀请:

张佳期

赞同来自:

这里面有个值表类型的demo
https://pro.arcgis.com/en/pro-app/arcpy/geoprocessing_and_python/defining-parameters-in-a-python-toolbox.htm  

值表1.gif

脚本如下:
import arcpy

class Toolbox(object):
def __init__(self):
"""Define the toolbox (the name of the toolbox is the name of the
.pyt file)."""
self.label = "test"
self.alias = "test"

# List of tool classes associated with this toolbox
self.tools = [testTool1]

class testTool1(object):
def __init__(self):
"""Define the tool (tool name is the name of the class)."""
self.label = "testTool"
self.description = "test"
self.canRunInBackground = False

def getParameterInfo(self):
in_fc = arcpy.Parameter(
name='in_features',
displayName='Input Features',
datatype='GPFeatureLayer',
direction='Input',
parameterType='Required')
vt = arcpy.Parameter(
name='summary_fields',
displayName='Image Time(optial)',
datatype='GPValueTable',
direction='Input',
parameterType='Optional')
vt.parameterDependencies = [in_fc.name]
vt.columns = [['GPString', 'Image Time'], ['GPString', 'Image Mosaic'], ['GPString', 'Image Layer']]
vt.filters[0].type = 'ValueList'
vt.filters[0].list = ["2019","2020"]
vt.filters[1].type = 'ValueList'
vt.filters[1].list = ["xqx2019","xqx2020"]
vt.filters[2].type = 'ValueList'
vt.filters[2].list = ["tc2019","tc2020"]
vt.values = [['2019', 'xqx2019','tc2019']]

params=[in_fc,vt]

return params

def isLicensed(self):
"""Set whether tool is licensed to execute."""
return True

def updateParameters(self, parameters):

return

def updateMessages(self, parameters):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return

def execute(self, parameters, messages):
"""The source code of the tool."""

return

要回复问题请先登录注册