1) I've read the docs ( customize tool behavior )
2) I've received excellent feedback in a related post ( related post )
3) And followed similar workflow examples ( Arcpy paramaters example )
My observation is that people use `param.valueAsText for some reason as validation that a parameter has been entered. Others mix and match param.altered for a similiar purpose. While others use hasBeenValidated. Reposting this example from the ESRI docs - 1) above:
def updateParameters(self, parameters):
# Set the default distance threshold to 1/100 of the larger of the width
# or height of the extent of the input features. Do not set if there is no
# input dataset yet, or the user has set a specific distance (Altered is true).
#
if parameters[0].valueAsText:
if not parameters[6].altered:
extent = arcpy.Describe(parameters[0]).extent
if extent.width > extent.height:
parameters[6].value = extent.width / 100
else:
parameters[6].value = extent.height / 100
return
Why not do this:
def updateParameters(self, parameters):
if parameters[0].altered:
if not parameters[6].altered:
#continue
My questions in relation to this example are:
1. What is the difference between altered and hasBeenValidated and can a paramaters be UNaltered and validated and altered and UNvalidated.
2. When does validation occur?
3. Is valueAsText/value just a syntactically awkward way of checking if a paramater has been set? (I understand we can assign new values with this property)
3. when to use value vs. valueAsText - i.e.
if param[0].<value or valueAsText:
# do something
My guess is that valueAsText/value is way overused and due to sparse documentation people made their Python Toolboxes work by misusing these properties. Hence my attempt to clarify my understanding.
Thanks,
Zach