This supported at 10.3 and later.
Defining parameters in a Python toolbox—Help | ArcGIS for Desktop : Creating value table parameters
Could you tell me how to make a parameter like this as I circled as below? I need to a parameter can be used to show a table content? Thanks.
I know this is an old post, but I have been struggling with this as well and wanted to post a solution. I was able to figure out a very clunky workaround that does allow you to create your own drop down. In my case, I did not actually use a "Field" value for the first part of the drop down but rather a list of Land use values derived from an input table's field values.
By using suggestions from David Wynne above, I was able to "trick" the GP framework with a Python toolbox. I made a copy of the Summary Statistics parameter as suggested, then modified the parameter filter lists like this:
parameters[7].filters[1].list = ['some_list', ...]
And the relevant code:
# global var CURVE_NUMS = [[u'Agricultural', 30.0, 58.0, 71.0, 80.0, 30.0], ...]# more values ommitted def getParameterInfo(self): fmap = arcpy.GetParameterInfo("Statistics_analysis")[2] 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[4].value: if parameters[4].valueAsText != LULC_FIELD and not parameters[6].altered: setattr(sys.modules[__name__], LULC_FIELD, parameters[4].valueAsText) with arcpy.da.SearchCursor(parameters[3].valueAsText, [parameters[4].valueAsText]) as srows: lulc_vals = sorted(list(set([str(r[0]) for r in srows]))) # get land use values from field parameters[6].values = CURVE_NUMS # create dummy table parameters[7].value = [[l, ' '] for l in lulc_vals] #assign a default of " " so the user can fill in drop down parameters[7].filters[1].list = [r[0] for r in CURVE_NUMS] # IMPORTANT, update the filter list from summary stats to your own list return
And the drop down:
This is not customizable, as you can only use the two columns and you cannot rename the parameter, but it does work. Hopefully Esri supports this behavior in the future.
It would be nice if you could set a list filter for multiple columns like this:
parameters.filter.list = [[list1,...], [list2]]
Hi RichardMany thanks for your advice and links - really helpful.While I admit I am not a python expert I have created scripts to automate many of our workflows and have included validation scriptswith these so have more than a basic knowledge.What I am hoping to achieve is a combination of using a featureset and recordset or attribute lists to add multiple species to a ecology habitat type...the user will click a point to add a habitat type which can be from a feature template or a list parameter...the habitat type selected will determine the species list dropdown - i can do this already using the vaildation script to change the species tick list...BUT...if possible I would really like to also include an abundance attribute (D, A, F, O, R) for each species and this is not possible at the moment as the value list defaults to a ticklist - do you know if it is possible to create a value table for string parameters?or would I be better off going the .net route? if so where is the best place to get started?Any pointers are much appreciated.CheersTim
I am trying to create a Python Toolbox in ArcGIS 10.1 and can't seem to replicate something like what I see in the Summary Statistics tool where the user builds a Value Table that contains a list of Fields and then within the table the user must pick from a list of valid Statistic types (SUM, MEAN, etc). Anyone have an idea or experience doing this? Thanks.
def getParameterInfo(self): in_table = arcpy.Parameter( name="in_table", displayName="Input Table", datatype="Table View", direction="Input", parameterType="Required") stats_field = arcpy.GetParameterInfo("Statistics_analysis")[2] stats_field.parameterDependencies = [in_table.name] return [in_table, stats_field]
Les membres connectés peuvent publier, suivre les mises à jour, et plus encore. Nouveau ici ? Inscrivez-vous gratuitement.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.