I am quite new to Python, hence I would really appreciate some hints on the following:I need a value list which allows the user to select multiple values. Based on this selection, I need to update the first column of a value table with 2 columns. The second column is meant for the user to input values.I am trying this in a Python toolbox.
Many thanks in advance!
My code looks something like that at this point:
import arcpy
class Tool(object): def init(self): """Define the tool (tool name is the name of the class).""" self.label = "Tool" self.description = "" self.canRunInBackground = False
def getParameterInfo(self): """Define parameter definitions""" param0 = arcpy.Parameter( displayName = "Select_technology", name = "Technology_dropdown", datatype = "GPString", parameterType = "Required", direction = "Input", multiValue=True) param0.filter.type = "ValueList" param0.filter.list = ["Wind_onshore","Wind_offshore","PV"] param1 = arcpy.Parameter( displayName = "Buffers", name = "Value_table", datatype = "GPValueTable", parameterType = "Required", direction = "Input") param1.columns =([["String", "Buffer_name"], ["Long","Buffer_size"]]) params = [param0,param1] return paramsdef isLicensed(self): """Set whether tool is licensed to execute.""" return Truedef updateParameters(self, parameters): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" if str(parameters[0].value) == ["Wind_onshore"]: vtab = [] vtab.append(["Airports",None]) vtab.append(["WaterBodies",None]) parameters[1].values = vtab elif str(parameters[0].value) == ["Wind_offshore"]: vtab = [] vtab.append(["Eu",None]) vtab.append(["Tu",None]) parameters[1].values = vtab returndef updateMessages(self, parameters): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" returndef execute(self, parameters, messages): """The source code of the tool.""" return
أكثر...
Many thanks in advance!
My code looks something like that at this point:
import arcpy
class Tool(object): def init(self): """Define the tool (tool name is the name of the class).""" self.label = "Tool" self.description = "" self.canRunInBackground = False
def getParameterInfo(self): """Define parameter definitions""" param0 = arcpy.Parameter( displayName = "Select_technology", name = "Technology_dropdown", datatype = "GPString", parameterType = "Required", direction = "Input", multiValue=True) param0.filter.type = "ValueList" param0.filter.list = ["Wind_onshore","Wind_offshore","PV"] param1 = arcpy.Parameter( displayName = "Buffers", name = "Value_table", datatype = "GPValueTable", parameterType = "Required", direction = "Input") param1.columns =([["String", "Buffer_name"], ["Long","Buffer_size"]]) params = [param0,param1] return paramsdef isLicensed(self): """Set whether tool is licensed to execute.""" return Truedef updateParameters(self, parameters): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" if str(parameters[0].value) == ["Wind_onshore"]: vtab = [] vtab.append(["Airports",None]) vtab.append(["WaterBodies",None]) parameters[1].values = vtab elif str(parameters[0].value) == ["Wind_offshore"]: vtab = [] vtab.append(["Eu",None]) vtab.append(["Tu",None]) parameters[1].values = vtab returndef updateMessages(self, parameters): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" returndef execute(self, parameters, messages): """The source code of the tool.""" return
أكثر...