I am creating an ArcPy scripting tool to allow users to select a feature from a feature layer and then zoom to that selection. I have successfully created this tool and now am working on creating the parameters.

I want the user to be able to view a dropdown list of the allowable selections (taken from a field within the attribute table of the feature layer). I currently have the parameter set as a sql expression- however this would require the user to type in more information than they probably know. How can I create a populated dropdown list for the parameter that will correctly input the sql expression? I have attached my code below.

import arcpy
Selection = arcpy.GetParameterAsText(0)
mxd = arcpy.mapping.MapDocument("CURRENT")
dataFrame = arcpy.mapping.ListDataFrames(mxd, "*")[0] 
arcpy.SelectLayerByAttribute_management("PLSS.lyr","NEW_SELECTION", Selection)
  • I would be very interested to see your tool as have a similar thing I've tried to do in the past. Please let me know if you are willing to upload it somewhere. Thanks.
    – J-Hurter
    Commented Mar 16, 2016 at 10:11

1 Answer 1


From line 2, it looks like your code is intended as a Toolbox script tool. Under Toolbox -> Tool -> Properties -> Parameters tab, select the Selection parameter and click next to Filter in the Parameter Properties box. This will give you a drop-down - click "Value List." If you have expressions in mind for specific feature layers - parcels or addresses, for example - you can then input those as entries in the value list.

If you want to make it even more user friendly, you can populate the list with memorable names like "Select Parcels By Address" and have those be keys to a Python dictionary - "Select Parcels By Address" would return a SQL expression string to use in the query function.

  • Second paragraph is an excellent (and easily overlooked) idea
    – Midavalo
    Commented Mar 14, 2016 at 18:36
  • Only if you can predict what your users are going to want to run SQL on, and restrict it to just those. If you try to build expressions for every possible use case in your catalog, you'll be overwhelmed pretty fast. I have been there, and it is not fun. But it sounded like OP had a specific layer in mind to build this tool around. Commented Mar 14, 2016 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.