Select to view content in your preferred language

Issue with reapplying symbology to the layer in the arcpy

125
1
10-21-2025 09:45 AM
LiubovDumarev
New Contributor

I am working under a toolbox which shall at some point reapply saved symbology from the saved lyrx file.

And this line of code is not working even though the lyrx file is present and is correct with a correct path. What is the problem?

aprx = arcpy.mp.ArcGISProject("CURRENT")
active_map = aprx.activeMap
lyr = active_map.addDataFromPath(feature_path)
sym_name = os.path.basename(out_table)
sym_path = os.path.join(arcpy.env.scratchFolder, f"{sym_name}_sym.lyrx")
arcpy.management.ApplySymbologyFromLayer(lyr, sym_path)
0 Kudos
1 Reply
Robert_LeClair
Esri Esteemed Contributor

Hard to tell without seeing the entire python script but one thing stands out to me.  The line:

sym_name=os.path.basename(out_table) may not be quite right.  Try:

sym_name=os.path.basename(feature_path)

0 Kudos