parameter dependencies fc to field python toolbox

3619
1
Jump to solution
02-07-2013 04:22 PM
forestknutsen1
MVP Regular Contributor
so I have been looking but I can not seem to find how to populate a input field parameter that is based on the fc parameter. please note the dependence for p2.

import arcpy   class Toolbox(object):     def __init__(self):         """Define the toolbox (the name of the toolbox is the name of the         .pyt file)."""         self.label = "Toolbox"         self.alias = ""          # 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 = "Tool"         self.description = ""         self.canRunInBackground = False      def getParameterInfo(self):         """Define parameter definitions"""             # First parameter         p1 = arcpy.Parameter(             displayName="Input Features",             name="in_features",             datatype="Feature Layer",             parameterType="Required",             direction="Input")          p2 = arcpy.Parameter(             displayName="Input Field",             name="in_field",             datatype="Field",             parameterType="Required",             direction="Input")          p2.parameterDependencies = ????          p3 = arcpy.Parameter(             displayName="Input String",             name="in_string",             datatype="String",             parameterType="Required",             direction="Input")          return [p1, p2, p3]       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."""         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."""         in_fc = parameters[0].valueAsText         in_field = parameters[1].valueAsText         in_string = parameters[2].valueAsText          rows = arcpy.UpdateCursor(in_fc)          for row in rows:             row.setValue(in_field, in_string)             rows.updateRow(row)          del row, rows          return
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
forestknutsen1
MVP Regular Contributor
found it.

  p2.filter.list = ['Text']   p2.parameterDependencies = [p1.name]

View solution in original post

0 Kudos
1 Reply
forestknutsen1
MVP Regular Contributor
found it.

  p2.filter.list = ['Text']   p2.parameterDependencies = [p1.name]
0 Kudos