You could do this in a rough way using the "SQL Expression" parameter type (make sure it is set to "obtained from" the Input_Data parameter).Another fancier way is to build up some "validation" code. Here's an examples of what a clever coworker of mine came up with to included a toolbox pick list that gets populated with the folder names in a certain directory. I haven't messed with it yet (that's for next week, so I can't really answer many questions about it), but seems like it could be easily altered to give you the unique field values of your selected features using a searchcursor applied to the input featurelayer. import os
class ToolValidator:
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""
basePath = r"\\snarf\am\div_lm\ds\for_inv\data"
def __init__(self):
"""Setup the Geoprocessor and the list of tool parameters."""
import arcgisscripting as ARC
self.GP = ARC.create(9.3)
self.params = self.GP.getparameterinfo()
self.fripnameParam = self.params[0]
self.fristypeParam = self.params[1]
return
def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
self.fristypeParam.Value = self.fristypeParam.Filter.List[0]
self.updateFripnamePickList()
return
def updateParameters(self):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parmater
has been changed."""
self.updateFripnamePickList()
return
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
fripname = self.fripnameParam.Value
fristype = self.fristypeParam.Value
if fripname and fristype:
if not os.path.isdir(os.path.join(self.basePath, fristype, fripname)):
self.fripnameParam.SetErrorMessage(fripname + " does not exist")
return
def updateFripnamePickList(self):
pickList = []
for d in self.listSubdirectories(os.path.join(self.basePath, self.fristypeParam.Value)):
pickList.append(d)
self.fripnameParam.Filter.List = pickList
return
def listSubdirectories(self, directory):
subdirectories = []
for f in os.listdir(directory):
if os.path.isdir(os.path.join(directory, f)):
subdirectories.append(f)
return subdirectories
# The thing in square brackets (next line) is a "list comprehension".
#return [f for f in os.listdir(directory) if os.path.isdir(os.path.join(directory, f))]