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.""" self.params[1].parameterDependencies = [0] # set the parameter dependency for Field to the FC 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.""" import arcpy FC = self.params[0].value fldName = self.params[1].value vList = [] #use a cursor to get values of selected field into vList rows = arcpy.SearchCursor(FC) for row in rows: fldVal = str(row.getValue(fldName)) vList.append(fldVal) self.params[2].filter.list = vList #fill the Values Parameter with the selected field´s values return def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return
Thanks very much. This is exactly what I needed to accomplish and I learned about validation in the processes.
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.