PYT: Change Symbology Based on User Selection

Discussion created by rickasselin on Feb 26, 2014
Latest reply on Feb 26, 2014 by rickasselin
I have a Python toolbox that creates an output GPFeatureLayer from some analysis (that part works fine), but I also have a ValueList parameter with 3 options for how to symbolize the output.  I point the output GPFeatureLayer's default symbology in the getParameterInfo method a "red" .lyr file:
in_Sym = arcpy.Parameter(
[INDENT]displayName = "Output Symbology",
name = "in_Sym",
datatype = "GPString",
parameterType = "Required",
direction = "Input")
in_Sym.filter.type = "ValueList"
in_Sym.filter.list = ["red", "green", "blue"]
in_Sym.value = "red"

out_Plygns = arcpy.Parameter(
[INDENT]displayName = "Output Polygons",
name = "out_Plygns",
datatype = "GPFeatureLayer",
parameterType = "Derived",
direction = "Output")[/INDENT]
out_Plygns.symbology = os.path.join(os.path.dirname(__file__), "symbologyRED.lyr")

Then in the execute method, I create a feature layer (outPgs_FL in the code below), do the analysis, and then I have an if statement to change that to green or blue .lyr files based on the user's choice, and I set my output GPFeatureLayer to outPGS_FL:
if (in_Sym == "red"):
[INDENT]parameters[5].symbology = os.path.join(os.path.dirname(__file__), "symbologyRED.lyr")[/INDENT]
elif (in_Sym == "green"):
[INDENT]parameters[5].symbology = os.path.join(os.path.dirname(__file__), "symbologyGREEN.lyr")[/INDENT]
elif (in_Sym == "blue"):
[INDENT]parameters[5].symbology = os.path.join(os.path.dirname(__file__), "symbologyBLUE.lyr")[/INDENT]

parameters[5].value = outPgs_FL

Problem is, it always sticks with the default red.  I tried removing the default symbology from the getParameterInfo method (no luck).  I even tried setting the symbology in the updateParameters method, but that didn't work either. 

Any suggestions?