AnsweredAssumed Answered

Drop down field list in a pyt value table

Question asked by granthay on May 8, 2018

Hi all,

I'm building a tool that uses a value table as it's input. What I'd like is to have a drop down list of fields to choose from for each input layer. I've seen a number of posts about this topic but all of them were processing just one input layer, I have yet to see someone do it for multiple inputs. I'm sure someone here has done it before


#import system modules


import arcpy
import traceback
import os


#initialize tool

class Toolbox(object):
   def __init__(self):
   """Define the toolbox (the name of the toolbox is the name of the
   .pyt file)."""
      self.label = "ACLOSAN_Constraint_Layer_Tool"
      self.alias = "ACLOSAN_Constraint_Layer_Tool"

      # List of tool classes associated with this toolbox = [Tool]

class Tool(object):
   def __init__(self):
   """Define the tool (tool name is the name of the class)."""
      self.label = "ALCOSAN_Constraint_Tool"
      self.description = "The purpose of this tool is to process and union layers related to green infrastructure       development. The tool will process the data according to whether it is absolutely or relatively constrained."
      self.canRunInBackground = False

def getParameterInfo(self):

# input value table
   Inputs = arcpy.Parameter(
      displayName="Input Features",
      datatype= "GPValueTable",

   Inputs.columns = [["DEFeatureClass", "Input Layer"], ["GPString", "Constraint Type"], ["GPString", "Constraint Field"],   ["GPDouble", "Relative Constraint"], ["GPDouble", "Buffer Distance"]]

   RC_output = arcpy.Parameter(
      displayName="Relative Constrained Union Output",

   ABS_output = arcpy.Parameter(
      displayName="Absolutely Constrained Union Output",

   Inputs.filters[1].list = ["Absolute", "Relative"]
   Inputs.filters[1].type = "ValueList"

   params = [Inputs , RC_output, ABS_output]

return params

def isLicensed(self):
   """Set whether tool is licensed to execute."""
   return True

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[0].value and parameters[0].altered:
#something has to happen here to return the fields


def updateMessages(self, parameters):
   """Modify the messages created by internal validation for each tool
   parameter. This method is called after internal validation."""

def execute(self, parameters, messages):
   """The source code of the tool."""
   #for fld in arcpy.GetParameterAsText(0):
   #print fld