ArcGIS 10 ToolValidator - Empty feature class and feature class within declared featu

المشرف العام

Administrator
طاقم الإدارة
I'm new to ToolValidator for a script tool and I'd like to make two checks which then adds an error if either rule is violated.I need to make sure parameter 2 and 3 (feature classes) are within parameter 1 (feature dataset). The tool will fail (roughly 3/4 of the way through) if the feature classes are not contained in the feature dataset.

Also, the tool needs to display an error is the feature class is empty.

I know Tool Validator is the way to go. I don't have much and am willing to read stuff. Also, this doesn't work, but I've managed to piece it together with some other posts. Thanks.

import arcpyclass ToolValidator(object): """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.""" returndef updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parameter has been changed.""" if self.params[3].value==True: self.params[3].enabled==True fc=self.params[3] rows = arcpy.SearchCursor(fc) if rows.next(): self.params[3].enabled==True else: self.params[3].enabled==False returndef updateMessages(self):"""Modify the messages created by internal validation for each toolparameter. This method is called after internal validation."""return if self.params[3].hasBeenValidated: self.params[3].clearMessage() else: self.params[3].setErrorMessage('Your feature class is empty. 300 Tool will not fail.')

أكثر...
 
أعلى