Hello ESRI community,
I'm working on a python toolbox that will have many variables that the user can change. I'm trying to find a way to do this without having dozens of parameters in my arcpy toolbox, which will make maintenance of this tool an absolute nightmare.
To give a quick summary, I have several categories, and within each category there maybe be 6 to 10 variables that the user can change. The way I structured the tool is to save a JSON for each category (this also allows me to save state between runs).
Within getParameters, the user chooses a category from a dropdown list:
var_name = arcpy.Parameter(
displayName="Variable Name",
name="var_name",
datatype="GPString",
parameterType="Required",
direction="Input")
var_name.filter.list = ["Category1", "Category2", "Category3", "Category4"]
and for each of these categories, there's another parameter which contains the JSON:
category1 = arcpy.Parameter(
displayName="Category 1",
name="category1 ",
datatype="GPString",
parameterType="Required",
direction="Input")
category1.enabled = 0
This is always disabled, and the user doesn't see it. It contains a string of a JSON that might looks like this:
{'var1': 10, 'var2' :20, 'var3': 30, 'var4': 40, 'var5': 50, 'var6': 60, 'var7': 70, 'var8': 80}
Then I'll have a parameter for each of these vars, which is enabled and populated from the parsed JSON when the relevant category is chosen and disabled otherwise. As you can tell by doing some simple math, this will result in 50+ parameters (yikes). My plan was to have 8 parameters that simply get recycled between categories, but that was foiled when I discovered you can't change the displayName property in updateParameters.
Is there a way to structure this tool so users can modify the many variables without having so many parameters? I'm not sure if the question was clear enough, I'm happy to clarify if helpful.