Hi. I want to create a script tool that let's the user select one or more Line ID and set a definition query and I want to choose from a list based on the Line ID field in the feature class (SetParameter?). How can I do that? Not sure if I need to append to a list and if an expression can grow or shrink depending on how many values are selected.
e.g. LineID = '0001' OR LineID = '0002'..................................
Here is the simple (single value) version:
import arcpy Line_ID = arcpy.GetParameterAsText(0) mxd = arcpy.mapping.MapDocument("Current") df = arcpy.mapping.ListDataFrames(mxd, "*") layer = arcpy.mapping.ListLayers(mxd, "Lines") sc = set(r for r in arcpy.da.SearchCursor(layer, "LID")) for s in sc: where_clause = "LID = '"+Line_ID+"'" layer.definitionQuery = where_clause ext = layer.getExtent() df.extent = ext del mxd, df, layer, sc, s