I am new to Python toolboxes. I have 2 parameters, param0 is an input text file, param1 is an output feature class.
I want param1 disabled,
which works fine, once it is enabled, I want it blank,
but it is populated with "C:\Users\Dave\Documents\ArcGIS\Default.gdb\test_CreatePolygon"
def updateParameters(self, parameters):
"""Modify the values and properties of parameters before internal
validation is performed. This method is called whenever a parameter
has been changed."""
if ( parameters[0].value):
parameters[1].enabled = True
parameters[1].value = ""
return
You don't need the parentheses around the if condition... does removing those change the outcome?
I don't know if I follow exactly what you're getting at here, but I think you need to actually return something from your method; probably parameters. Right now your changing the .enabled and .value attributes of parameters[1], but those changes are only in the local variables for the method, they don't go anywhere. Try this at the end.
return parameters
Then I'm assuming you use parameters as input for some other process or method, in which case it should have the new properties you set in updateParameters().
Thank you, Adam Cox, for the clarification.
No, see this documentation: ArcGIS Help 10.1 Go down to the examples and you'll see that, just like in the normal ToolValidator class for script tools (i.e. not in a Python toolbox), the updateParameters() method does not return any objects.
I didn't realize this is was something that Esri designed. Thanks for the clarification.