AnsweredAssumed Answered

In python toolbox, can you have parameters update more than once?

Question asked by rmboynton on Oct 1, 2015

I'm building a python toolbox that has 6 parameters. The toolbox is either creating a row in an underlying table, or updating a row if one already exists for the value in parameter 2. I have figured out how to automatically load values from the underlying table for parameters 3-6 when a value is selected in parameter 2. What I can't figure out how to do, is to update parameters 3-6 if the user selects a different value in parameter 2 (since the altered property is read-only so I can't reset it). Is this possible?

 

Here is the updateParameters section of my code:

 

    def updateParameters(self, parameters):

        """Modify the values and properties of parameters before internal

        validation is performed.  This method is called whenever a parameter

        has been changed."""

 

        if parameters[0].value:

            UPGDB = parameters[0].valueAsText

            picklepath = "\\".join([UPGDB,"UPConfig.p"])

            UPConfig = uiut.LoadPickle(picklepath)

            parameters[1].filter.list = [ts[0] for ts in UPConfig['TimeSteps']]

 

        if parameters[1].altered:

            #the user selected a timestep...see if that timestep already has demographics

            #if so, populate the other parameters with the values in the upd_demographics table

            UPGDB = parameters[0].valueAsText

           

            dpicklepath = "\\".join([UPGDB,"UPDemand.p"])

            UPDemand = uiut.LoadDemandPickle(dpicklepath)

               

            TSCode = parameters[1].valueAsText

           

            if parameters[2].value == None:

                parameters[2].value = UPDemand[TSCode]['StartPop']

            if parameters[3].value == None:

                parameters[3].value = UPDemand[TSCode]['EndPop']

            if parameters[4].value == None:

                parameters[4].value = UPDemand[TSCode]['PPHH']

            if parameters[5].value == None:

                parameters[5].value = UPDemand[TSCode]['EPHH']

           

        return

Outcomes