AnsweredAssumed Answered

Python Toolbox-populate drop-down with field values

Question asked by BrianK on Jan 3, 2016
Latest reply on Jan 4, 2016 by BrianK

Hi,

There are a few discussions on this topic but I'm not finding the solution I need or it is right in front of my face and I'm missing it completely.

 

I'm using Desktop 10.3.   I'm am trying to create a geoprocessing tool with the input dialogue box requesting the user to select:

 

1. Feature class  e.g US States

2. Field with the States name in the Feature Class  e.g. stateNames

3. A drop-down of the 50 states where the user can select one of the states.

 

I'm trying to use the python toolbox tool template (portion shown below).  I'm able to populate a drop-down of the fields and now need to have the user select a value from the field.

 

Any suggestions?

 

Thanks

Brian

 

class tool(object):

    def __init__(self):

        """Define the tool (tool name is the name of the class)."""

        self.label = "tool"

        self.description = ""

        self.canRunInBackground = True

 

    def getParameterInfo(self):

       # first paramter

        in_feature = arcpy.Parameter(

           displayName = "Feature with States",

           name = "in_feature",

           datatype = "Feature Layer",

           parameterType = "Required",

           direction = "Input")

 

        stateField = arcpy.Parameter(

           displayName = "Field with State Names",

           name = "stateField",

           datatype = "Field",

           parameterType = "Required",

           direction = "Input")

 

        stateField.filter.list = ['Text']

        stateField.parameterDependencies = [in_feature.name]

 

        stateName = arcpy.Parameter(

           displayName = "Select one State",

           name = "stateName",

           datatype = "GPValueTable",

           parameterType = "Required",

           direction = "Input")

      return

 

    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."""

        return

Outcomes