GSCUser85

Tool validator query

Discussion created by GSCUser85 Champion on Oct 22, 2013
Latest reply on Oct 23, 2013 by GSCUser85
I think I am reasonably competent at python / arcpy coding. But mostly I use this as py code running straight out of IDLE.
Its quick and easy, but all the data sources / outputs are hard coded.

So recently I have become inspired to turn some of my more re-usable code into proper scripts in a tool box.

This tool takes in a PointZ Fc and uses its attribute data to create a polylineZM of the drill hole trace.
You can see from the attachment that I have successfully disabled the second half of the dialog until an associated table is selected.
No probs there.
So a couple of questions to those of you with more experienced than me with coding the tool validator classes.
I wanted to make sure that the user selects 3 different attribute fields for the numeric inputs. Selecting 2 that are the same would be nonsense.
I tried to do this in updateParameters like this:
if self.params[3].value and self.params[4].value:
      if self.params[3].value == self.params[4].value:
        self.params[4].setErrorMessage("Cannot pick the same field")
      else:
.....

But this didn't really do anything. No little red crosses appeared and the tool ran anyway.
So is there an easier way to ensure that 3 different inputs are picked that I havn't noticed yet?
Or what would be the correct way to do this in a toolvalidator.

I have read (and re-read) all the help stuff on this but can find no pointers yet on how to do this.
Also looked at some of the videos from Dev Summit 2012 re tool scripting.

Thanks in advance,
Neil

Attachments

Outcomes