I am having a strange issue that I can't seem to figure out. I am writing a simple script that will automate a map production workflow. In part of the script, I import a new feature class as a layer, change it's symbology to an existing feature layer in the map, and then change the extent of the map frame to the new feature layer. Here is a snippet...
# SPECIFY AREA OF INTEREST
#SYMBOLOGY WORKS CORRECTLY WHEN I PROVIDE A TRUE PATH TO A FEATURE CLASS
AOI = r"G:\Users\Parcels.gdb\Arcadia"
#FAILS WHEN I PROVIDE GETPARAMETERASTEXT FOR THE AOI
AOI = arcpy.GetParameterAsText(0)
# SPECIFY AN EXISTING ARC PRO PROJECT FILE
aprx = arcpy.mp.ArcGISProject('G:/Users/Project.aprx')
# OBTAIN THE MAP AND LAYOUT FROM THE PROJECT
mp = aprx.listMaps()[0]
lyt = aprx.listLayouts()[0]
# OBTAIN ELEMENTS FROM THE LAYOUT THAT WILL BE MODIFIED
elements = lyt.listElements()
map_frame = elements[15]
# ADD PARCEL TO THE MAP
mp.addDataFromPath(AOI)
# GET LAYERS FROM THE MAP
map_layers = mp.listLayers()
AOI_lyr = map_layers[0]
TTRS_lyr = map_layers[1]
# APPLY TTRS SYMBOLOGY TO NEW AOI
arcpy.ApplySymbologyFromLayer_management(AOI_lyr, TTRS_lyr)
# CENTER THE MAP AROUND THE NEW AOI
map_frame.camera.setExtent(map_frame.getLayerExtent(AOI_lyr))
# EXPORT THE MAP LAYOUT AS A PDF
lyt.exportToPDF("G:\Users\Map.pdf",resolution=300)
When I test the script line by line in a development environment (i.e PyCharm, etc.) the output maps are correct in their symbology. However, when I run it as a script tool (with GetParameterAsText), the symbology of the new layer is not correct. Please see the picture below for an example. Could GetParamterAsText be throwing something off here? I am otherwise uncertain what the issue could be here.
NOTE: I found similar posts that suggest this might be an existing bug in ArcGIS Pro, regarding the use of symbology in script tools. There must be some alternative solution?
Why would arcpy ApplySymbologyFromLayer tool not work in ArcGIS Pro Python window?
Adding feature class and applying symbology in ArcGIS Pro using ArcPy?
Making arcpy.ApplySymbologyFromLayer_management() work on CURRENT project of ArcGIS Pro