dodgyshamrock

Tool Validator script not working

Discussion created by dodgyshamrock on Feb 6, 2012
Latest reply on Feb 6, 2013 by fatih.dur
I am trying to write a script in the Tool Validator so that the user can choose one of three options in the first parameter, and based on the user's choice, the other 3 parameters are either enabled or disabled.  However, I cannot seem to get it to work properly.  Nothing happens in the tool when I change the first parameter.  My other 3 parameters are feature sets.  The "Add Records Interactively" part is greyed out while the "Use records from" is enabled in all of them.  My script is below:

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()
    print self.params

  def initializeParameters(self):
    self.params[1].category = "Feature Types"
    self.params[2].category = "Feature Types"
    self.params[3].category = "Feature Types"
        
    
    """Refine the properties of a tool's parameters.  This method is
    called when the tool is opened."""
    return

  def updateParameters(self):
    if self.params[0].altered:
      if self.params[0].value == "Point":
        self.params[1].enabled = 1
        self.params[2].enabled = 0
        self.params[3].enabled = 0
      elif self.params[0].value == "Line":
        self.params[1].enabled = 0
        self.params[2].enabled = 1
        self.params[3].enabled = 0
      elif self.params[0].value == "Polygon":
        self.params[1].enabled = 0
        self.params[2].enabled = 0
        self.params[3].enabled = 1

      """Modify the values and properties of parameters before internal
    validation is performed.  This method is called whenever a parmater
    has been changed."""
    return

  def updateMessages(self):
    """Modify the messages created by internal validation for each tool
    parameter.  This method is called after internal validation."""
    return


What am I doing wrong?  I'm completely stumped!

Thank you in advance for any help!

Amy

Outcomes