Select to view content in your preferred language

User not able to add values after setting self.param value in ArcGIS Python Script Tool

874
3
12-22-2022 03:04 AM
rachelxlb
New Contributor II

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?

rachelxlb_4-1671706914839.png

 

rachelxlb_1-1671706228562.png

rachelxlb_2-1671706305677.png

rachelxlb_0-1671706187280.png

rachelxlb_3-1671706599185.png

 

 

0 Kudos
3 Replies
by Anonymous User
Not applicable

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

 

0 Kudos
rachelxlb
New Contributor II

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?

0 Kudos
by Anonymous User
Not applicable

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)

 

0 Kudos