forked from Esri/photo-survey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Validation
59 lines (45 loc) · 1.88 KB
/
Validation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import arcpy
class 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."""
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):
"""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[0].value == 'Single Camera':
self.params[1].enabled = 1
self.params[2].enabled = 0
self.params[3].enabled = 0
self.params[4].enabled = 0
self.params[6].enabled = 0
self.params[7].enabled = 0
else:
self.params[1].enabled = 0
self.params[2].enabled = 1
self.params[3].enabled = 1
self.params[4].enabled = 1
self.params[6].enabled = 1
self.params[7].enabled = 1
return
def updateMessages(self):
"""Modify the messages created by internal validation for each tool
parameter. This method is called after internal validation."""
if self.params[0].value == 'Single Camera':
self.params[1].setErrorMessage("Photo folder required")
self.params[5].setErrorMessage("Staging Geodatabase required")
self.params[8].setErrorMessage("Survey question file required")
else:
self.params[2].setErrorMessage("Passenger side photos required")
self.params[3].setErrorMessage("Driver side photos required")
self.params[5].setErrorMessage("Staging Geodatabase required")
self.params[6].setErrorMessage("Parcel (polygon) feature class required")
self.params[7].setErrorMessage("Parcel Identification field required")
self.params[8].setErrorMessage("Survey question file required")
return