Hello everyone,
I'm wondering how I can give different GetParameteres when a certain variable is true.
For ex.
If a feature class has more than 1 feature in it I want it to use a different GP tool. I know I can do this in the script easily but I want users to enter in parameters in if the feature class has more than 1 feature in it.
Hi Adam,
You will need to apply Script Tool Validation to the tool. Take a look at the following example:
Customizing script tool behavior—Help | ArcGIS Desktop
You could specify something like:
def updateParameters(self):
result = arcpy.GetCount_management(self.params[3].value)
if int(result[0]) > 1:
self.params[8].enabled = 1
else:
self.params[8].enabled = 0
Awesome, thanks for the reply Jake.
So I would need to edit the code in the Validation tab?
see image.
Adam Arcichowski yes that is correct.
Jake,
Now that I think of it, I'm not sure if this will work because the "arcpy.GetCount_management" will not work on a kmz correct?
If I select a kmz with multiple features in it, can the Validation script run to convert the kmz to a feature layer than use the GetCount function and then have the other parameters come up ?
It can, but you may want to be careful with this approach. From the help:
Called each time the user changes a parameter on the tool dialog box. After returning from updateParameters, geoprocessing calls its internal validation routine.
You will want to make sure the tool is not running the KMZ conversion after each parameter is updated.