In the Validation tab in Tool Properties, I added a list of feature class to parameter #12 in the UpdateParameters function. The feature classes from the list were successfully loaded to in the prompt, but I'm not able add new values or delete values in the tool interface. As the first screenshot shown below, I couldn't delete any of the three or add a new value. I set the parameter as Feature Layer and checked the multiple values box. Is there any setting or any coding needed to enable user to add and delete values?
You can post code by click the ... and </> symbol.
I wish they would provide more examples for setting the Validation class. This creates a property in the class to hold the list of featureclasses, sets the parameter to a default list, and then updates/sets it if it is altered.
def __init__(self):
# set self.params for use in other function
self.params = arcpy.GetParameterInfo()
self.fcList = [r'path to fc\address', r'path to fc\address2', r'path to fc\creeks']
def initializeParameters(self):
# Customize parameter properties.
# This gets called when the tool is opened.
return
def updateParameters(self):
# Modify parameter values and properties.
# This gets called each time a parameter is modified, before
# standard validation.
if not self.params[1].altered:
self.params[1].value = '; '.join(self.fcList)
else:
self.fcList = self.params[1].value
self.params[1].value = '; '.join(self.fcList)
return
Thanks JeffK! This works for my first prompt, but I have two other prompts applying the same method/codes. It only works for the first one, doesn't work for the others. Does it happen to you as well?
If I follow, you'll have to set corresponding param checks for each parameter to get the ability to update those:
...
self.fcList2 = [r'path to fc\address', r'path to fc\address2', r'path to fc\creeks']
self.fcList3 = [r'path to fc\address', r'path to fc\address2', r'path to fc\creeks']
...
if not self.params[2].altered:
self.params[2].value = '; '.join(self.fcList2)
else:
self.fcList2 = self.params[2].value
self.params[2].value = '; '.join(self.fcList2)
if not self.params[3].altered:
self.params[3].value = '; '.join(self.fcList3)
else:
self.fcList3 = self.params[3].value
self.params[3].value = '; '.join(self.fcList3)