GDB Field Values to Script Value List

938
3
04-03-2011 08:07 AM
DaveCouture
New Contributor III
Is there a way to populate a String Value List (Filter) from the Values of a GDB Field?  We have hundreds of records in one of our GDB, that we update every month.  In our old system (Caris), we were able to create predefined queries (tools) for our users and I'm trying to create similar tools, with Scripts and the Model Builder.  For example, we had a drop down list with all the street names, in our city, and that list was being populated by the values of the StreetNames field, in the Streets MDB/ODBC (every time the tool is launched).

The Model Builder has a great tool called Get Field Value, but it only gets the first value of the field.  I really don't understand why the tool can't return multiple values - Get Field ValueS?

Any thoughts?
Tags (2)
0 Kudos
3 Replies
DaveCouture
New Contributor III
Thanks! I understand how it works, now. I was able to define a filter, from the script; which is something I was also trying to do. However, I can't seem to get your code to work. I always get the following error:

ERROR
updateParameters Execution Error: Runtime error : 'Parameter' object has no attribute 'Filter'



Here's the whole script:


class ToolValidator:
"""Class for validating a tool's parameter values and controlling
the behavior of the tool's dialog."""

def __init__(self):
"""Setup arcpy and the list of tool parameters."""
import arcpy
self.params = arcpy.GetParameterInfo()

def initializeParameters(self):
"""Refine the properties of a tool's parameters. This method is
called when the tool is opened."""
return

def updateParameters(self):

try:

rows=self.gp.searchcursor(self.params[0].Value)
row=rows.next()
KatKeyList=[]

while row:
KatValue=row.getvalue("PID")
if KatValue not in KatKeyList:
KatKeyList.append(KatValue)
row=rows.next()
KatKeyList.sort(locale.strcoll)
del row, rows
self.params[1].Filter.List=KatKeyList
except:
self.params[1].Filter.List=[]


def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
return
0 Kudos
JasonScheirer
Occasional Contributor III
Lower case 'f' on the param.filter attribute, and .list is lower case as well.
0 Kudos
DaveCouture
New Contributor III
Thanks, I got it!  I also forgot to include:

    import os, sys, arcgisscripting
    self.GP = arcgisscripting.create()
0 Kudos