Drop down field list in a pyt value table

431
0
05-08-2018 10:54 AM
GrantHaynes
Occasional Contributor

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
      self.tools = [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",
      name="in_features",
      datatype= "GPValueTable",
      parameterType="Required",
      direction="Input")

   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",
      name="RC_out_features",
      datatype="DEFeatureClass",
      parameterType="Optional",
      direction="Output")

   ABS_output = arcpy.Parameter(
      displayName="Absolutely Constrained Union Output",
      name="ABS_out_features",
      datatype="DEFeatureClass",
      parameterType="Optional",
      direction="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

   return

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

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

0 Kudos
0 Replies