Enabling tool parameters based on user input - ArcGIS Pro model builder

196
0
03-25-2021 02:20 PM
MargaretLawrimore
New Contributor

I have created a custom geoprocessing tool using python and set up the tool with a boolean parameter (param 3) that when selected enables one parameter (param 6) and disables two others  (params 4, 5) and when not selected does the opposite. I set it up using the below code in the validation section of tool properties. This works well when I just run the tool, but when I add it into model builder all parameters are always enabled. Is there a way to have it behave the same way in model builder as it does as a stand alone tool?

Note: I also included functionality so param 5's value list updates based on param 4' value and this works in model builder and as a standalone tool.

def updateParameters(self):
        self.params[3].enabled = True
        self.params[4].enabled = True
        self.params[5].enabled = False
        self.params[6].enabled = False
        if self.params[3].value == True:
            self.params[4].enabled = False
            self.params[6].enabled = True
        else:
            # Modify parameter values and properties.
            # This gets called each time a parameter is modified, before 
            # standard validation.
            if self.params[4].value == "Food":
                self.params[5].enabled = True
                self.params[5].filter.list = ["live animals", "cereal grains"]
            elif self.params[4].value == "Energy":
                self.params[5].enabled = True
                self.params[5].filter.list = ["base/minimum", "peak/maximum"]
            elif self.params[4].value == "Water":
                self.params[5].enabled = True
                self.params[5].filter.list = ["surface water", "ground water"]
            elif self.params[4].value == "Industrial":
                self.params[5].enabled = True
                self.params[5].filter.list = ["stone", "natural sands"]
            elif self.params[4].value == "Waste":
                self.params[5].enabled = True
                self.params[5].filter.list = ["MSW", "All"]
            elif self.params[4].value == "Services":
                self.params[5].enabled = True
                self.params[5].filter.list = ["Private", "non-transportation"]
        return

 

 

0 Kudos
0 Replies