I am attempting to provide the user a drop down list of field values based on a predefined shapefile or table. The string value users choose then needs to be taken by the script tool for use later in the script.
I have the 'drop down' value list dynamically populated using the following validation code:
def updateParameters(self):
self.params[2].filter.list = [str(val) for val in sorted(set(row.getValue('FC_field') for row in arcpy.SearchCursor("FC_path",None, None, 'FC_field')))]
return
I then have the following script tool code which attempts to retrieve and store that value:
#---Import system modules.---
import arcpy
ProjectName = arcpy.GetParameterAsText(0)
ProjectBoundaries_FC = arcpy.GetParameterAsText(1)
Airport = arcpy.GetParameterAsText(2)
arcpy.AddMessage("INPUT: Project Name (0): <" + ProjectName + ">.")
arcpy.AddMessage("INPUT: Project boundaries (1): <" + ProjectBoundaries_FC + ">.")
arcpy.AddMessage("INPUT: Project Airport (2): <" + Airport + ">.")
The tool Parameters are set according to the image:
When the script tool is executed the text editor window pops up (illustrated below). Once I close it the tool processing bar stops and the rest of the code which would utilize that value never runs. In other words, when I close the editor window the script tool reports processing completed without errors, but never processes the "AddMessage" code (illustrated in the following image).
I suspect this is largely due to my unfamiliarity with using validation code.
As requested, here is a screenshot of the tool window showing the tool parameter options in use.
I am using ArcGIS v10.1 for Desktop - Advanced (ArcInfo) License
I think the most interesting thing here is why the tools script pops up in the text pad editor window at all?