I'm a newbie and I am creating a toolbox for python. I have a parameter A about categories that need to be selected by the user, there are 5 categories. Parameter A selects a category, and parameter B and C show the default parameter when that category is selected. If the user has a measured value for parameter B or C, then they can also enter it themselves.
I have created the following code but it is not working properly. When I change the value of A, B and C do not change with it. What should I do, please?
import arcpy
default = {"Class A": [1.46, 1.50],
"Class B": [1.46, 1.70],
"Class C": [0.35, 1.50],
"Class D": [0.35, 1.80],
"Class E": [0.35, 1.50]}
class Interfacemodel(object):
def __init__(self) -> None:
self.label = "model"
self.description = """model"""
def getParameterInfo(self) -> list:
"""Define parameter definitions.
"""
Option = arcpy.Parameter(name="class",
displayName="class",
datatype="String",
parameterType="Required",
direction="Input")
choices = ["Class A", "Class B", "Class C", "Class D", "Class E"]
Option.filter.list = choices
Option.value = "Class A"
param0 = arcpy.Parameter(name="param0",
displayName="param0",
datatype="GPDouble",
parameterType="Required",
direction="Input")
param0.value = 1.46
param1 = arcpy.Parameter(name="param1",
displayName="param1",
datatype="GPDouble",
parameterType="Required",
direction="Input")
param0.value = 1.50
return [Option, param0, param1]
def updateParameters(self, parameters) -> None:
if parameters[0].altered:
if not parameters[1].altered:
parameters[1].value = default[parameters[0].valueAsText][0]
if not parameters[2].altered:
parameters[2].value = default[parameters[0].valueAsText][1]