Skip to main content

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. Thanks!

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)
dataFrame.zoomToSelectedFeatures()

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. Thanks!

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)
dataFrame.zoomToSelectedFeatures()

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)
dataFrame.zoomToSelectedFeatures()
Source Link
user65111
  • 111
  • 1
  • 7

Creating ArcPy scripting tool with dropdown box for sql expression choice

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. Thanks!

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)
dataFrame.zoomToSelectedFeatures()