1

I'm trying to set the values of one control (Multi-value, data type: string ) to another parameter control (Multi-value, data type: "any value" which produces a drop down with grid for items entered or selected with the add, delete, and re-ordering (up/down) buttons).

The goal is to use the reorder buttons on the 2nd control (of the auto-populated items) to reorganize the list by moving rows up and down, then taking the values out (as text type is fine) and processing them further.

The issue is that I can get the items to populate into the 2nd control (via the ToolValidator class, updateParameters method) but I can't change their order. If I use the text entry box to populate the grid, it will allow me to change the order of the items.

Here's the code snip:

    def __init__(self):
    """Setup arcpy and the list of tool parameters."""
    self.params = arcpy.GetParameterInfo()
    global PriorParam
    PriorParam = ""
 
    def initializeParameters(self):
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""
    global PriorParam
    PriorParam = ""
    return

    def updateParameters(self):
     global PriorParam, selected_items_list
     if self.params[2].value:
         domains = arcpy.da.ListDomains(self.params[2].value)
         self.params[3].filter.list = [domain.name for domain in domains if       domain.domainType == "CodedValue"]

     if self.params[3].value:
         domains = arcpy.da.ListDomains(self.params[2].value)
#Probably a more direct way to grab the actual domain object but this works for now.
         for domain in domains:
            if domain.name == self.params[3].value:
                coded_values = domain.codedValues
         self.params[5].filter.list = [val.encode('utf-8') for val,desc in coded_values.items()]

     if self.params[5].values  <> PriorParam:
        PriorParam = self.params[5].values
        working_param = self.params[5].values
        self.params[6].values =  working_param # .params[5].values
     else:
        arcpy.AddMessage("Param5 didn't change after validate review.")
     return

Even though the Up/Down arrows are enabled, they don't actually re-order the items. Am I using the wrong Data Type or is there some other storage location I should manually be moving the items from the "Code(s) to move" to get them into the SequenceTheMoveCodes parameter control?

parameters page

  • Here you are asking about a Python Toolbox tool so for a suitable code snippet can you provide the full code of a test.pyt that implements just the bit that you are asking about, please? – PolyGeo Mar 14 at 22:24
  • Are you selecting a value in the SequenceTheMoveCodes parameter control before trying to use the up/down arrows? – user2856 Mar 14 at 22:46
  • Hi PolyGeo, I've updated the code snippet, above, to include more of the class ToolValidator code. This is for a Python script tool, not a Python toolbox tool-- meaning I'm using the ESRI provider parameter input page/window vs writing it all myself. – T Hammer Mar 15 at 14:36
  • Why do you need the checkboxes? Why not just populate a dropdown for your last control that lets you open dropdown, select one of the codes, which adds it to the list. You proceed to do so until all codes are in there and then move them in the right order. – PhilippNagel Mar 15 at 14:38
  • Hi user2856- Yes, I'm clicking the row I want to move. The row "marker" moves up, but the row content ('Maybe' for this instance does not). Also, this may be related, but when I add rows from the Codes To Move parameter control (and they populate in the SequenceTheMoveCodes) control, I cannot add new items to SequenceTheMoveCodes list. I can however, add items when Sequence the move is empty-- and the SequenceTheMoveCodes manually added can be re-ordered.. – T Hammer Mar 15 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.