ApplySymbologyFromLayer not working from a script tool but does work in python window

379
0
09-29-2020 11:00 AM
SteveKoller
New Contributor

--SCRIPT BELOW--

import arcpy

currentMap = arcpy.GetParameterAsText(0)
buildingGBD = arcpy.GetParameterAsText(1)
series = arcpy.GetParameterAsText(2)

aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.listMaps(currentMap)[0]
lyrFile = r"Z:\Data\Series_10.lyrx"

for series_num in series.split(';'):
   buildingFC = r"{0}\{1}\{2}{3}".format(buildingGBD,"Numbering", "Series_", series_num)
   arcpy.AddMessage(buildingFC)
   try:
      #aprxMap.addDataFromPath(buildingFC)
      arcpy.management.ApplySymbologyFromLayer(buildingFC, lyrFile, None, "MAINTAIN")
      arcpy.AddMessage("Series_" + series_num + " added")
   except:
      arcpy.AddMessage("Series number does not exist")

This is the script tool I've brought into my model builder tool but when I try to use arcpy.management.ApplySymbologyFromLayer instead of aprxMap.addDataFromPath (which does work) so that I can get the symbology, nothing gets added to the map frame. No errors are given and when I run the same arcpy.management.ApplySymbologyFromLayer in the python window it works. Is this a known bug or am I doing something wrong. I am using Pro 2.6.0

0 Replies