I am trying to make a tool in which there are many sequence parameters (based on the same field of a feature class), and each of them is multi value to make a user choose from a check a list one or more value from values in this field.
If the same field's values I need to use in sequence parameters, but I want to avoid the duplication in selecting values in these sequence parameters, so how to adjust the validation code, so that if the user select definite value(s) in a parameter, that or these values can not be selected in the following parameter, unless that or these values are unselected in the previous parameters?
For example, if in a parameter the user select the value "Canada" based on a field for countries' names, I want to avoid the repeating of selecting the value "Canada" in a following parameter, that is also based on the same field for countries' names, unless the user return to the previous parameter and unselect or uncheck the value "Canada".
import arcpy
class ToolValidator(object):
def __init__(self):
"""Setup arcpy and the list of tool parameters."""
self.params = arcpy.GetParameterInfo()
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
return
def updateParameters(self):
if not params[0].value:
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
global previousProjectPath3
previousProjectPath3 = ""
if self.params[1].value and self.params[3].value:
self.params[4].filter.list = sorted({row[0] for row in arcpy.da.SearchCursor(self.params[1].value, self.params[3].value.value) if row[0]})
if self.params[1].value and self.params[3].value:
self.params[5].filter.list = sorted({row[0] for row in arcpy.da.SearchCursor(self.params[1].value, self.params[3].value.value) if row[0]})
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
if params[0].altered:
path = params[0].valueAsText
global previousProjectPath3
if previousProjectPath3 != path:
previousProjectPath3 = path
{}
button that enables you to format any highlighted code nicely.