introduce
There are verification parameters in the toolbox properties (as shown below). This part is mainly used to see whether the toolbox parameters meet our requirements. It mainly contains three functions, namely initializeParameters() called when opening the toolbox and called after modifying the parameter value. updateParameters(), set message prompts for parameters updateMessages().
operate
The function we mainly modify is updateParameters()
code
def updateParameters(self):
# 修改参数值和属性。
# 在标准验证之前,每次修改参数时都会调用该函数。
shpdescribe= arcpy.Describe(self.params[0].value)
if shpdescribe.shapeType == "Point":
self.params[1].enabled = False
self.params[2].enabled = False
else:
self.params[1].enabled = True
self.params[2].enabled = True
return
Results display
New toolbox
Open toolbox
Enter point data
Enter other types of data to restore the original number of parameters
Follow the WeChat public account to enter the arcpy technology exchange group