I have the following code:
from arcpy import env
env.overwriteOutput = True
env.workspace = r"PATH\SDE_CONNECTION.sde"
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd, "")
subbasinCode = arcpy.GetParameterAsText(0)
pdfName = subbasinCode + ".pdf"
queryString = "AREA_CODE =" + "'" + subbasinCode + "'"
subbasins = "SDE.SEWERMAN.SUBBASIN"
subbasinSymbol = r"PATH\Subbasin_Selection.lyr"
subbasinSelect = arcpy.MakeFeatureLayer_management(subbasins,
arcpy.AddMessage("Symbology applied to subbasin selection.")
When I run this code in the python console in ArcMap (hardcode the subbasinCode variable) it runs fine. It replaces the existing Subbasin_Selection layer with the new selection from the MakeFeatureLayer function then applies the symbology.
When I create the script tool and run it the original Subbasin_Selection layer is removed from the map but the new subbasin isn't added.
The original code was much longer and it would use data driven pages to create a map book and export it based on the subbasin selection. It ran fine a a standalone script. I simplified it to figure out what is going on.
Any ideas on why it won't work in a script tool?