Python toolbox default parameter to get updated automatically?

671
4
10-31-2013 10:31 AM
ionarawilson1
Occasional Contributor III
I have a python toolbox defining the default parameter of a tool based on a value in a combobox created with a python add-in. The code works, but I have to manually refresh the tool everytime I change the values in the combobox. Is there a way for this python toolbox default parameter to get updated without the manual refresh? Thanks

        import Comboboxes_addin
       
        # the default values
        param2.value = Comboboxes_addin.combobox_1.value
Tags (2)
0 Kudos
4 Replies
JasonScheirer
Occasional Contributor III
Why don't you do the all of the inputs as parameters in the geoprocessing tool? I'm having trouble understanding why you also need an add-in to pre-fill what are essentially input parameters for a tool.
0 Kudos
ionarawilson1
Occasional Contributor III
Because I have a bunch of other tools and the user sometimes will not know which tool to use. So these comboboxes would tell him which tool to use through a message box and it would define the parameter defaults based on the choices he already selected on the combobox.
0 Kudos
ionarawilson1
Occasional Contributor III
Do you have any examples of a python toolbox filtering the list of a second parameter based on the selected item in a first parameter? Thanks
0 Kudos
ionarawilson1
Occasional Contributor III
I think I got it, I just need to learn how to reference a tool's property inside another tool.

  params = [param0, param1]
        activity = [" "]
        if params[0].value == "Forestry":
            activity = ["SP", "SPR", "MPR"]
        
        param0.filter.list = ["Forestry", "OW",

                                    "Urban Fire", "ED/PR"]

                       
        param1.filter.list = activity

        return params       
    def isLicensed(self):
        """Set whether tool is licensed to execute."""
        return True

    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 == "Forestry":
            activity = ["SP", "SPR", "MPR"]
        
            parameters[1].filter.list = activity
                       
        return
        
0 Kudos