I am stuck with this issue for days, and yet I could not find a solution.
Long story short, the "arcpy.ApplySymbologyFromLayer_management" simply does not work. The code runs without any issue, I can see the layer briefly locking on ArcPRO, but zero results.
My code:
aprx = arcpy.mp.ArcGISProject("CURRENT")workspace = "C:\whatever.gdb" arcpy.env.workspace = workspace
ref_lyrx = r"C:\SimbologyIwant.lyrx"
map = aprx.listMaps('Map')[0]
layers = map.listLayers()[0]
layers2 = map.listLayers()[1]
arcpy.ApplySymbologyFromLayer_management(layers2, layers)
I also tried
arcpy.ApplySymbologyFromLayer_management(layers2, ref_lyrx)
which uses the a layer file instead of a layer on the map. parameters
I refreshed, I ran the code with the map closed, added the optional p, tried all variations that I could think of. The code runs, but the symbology never changes.
Anyone has a sample code that works? Or any idea why my code has no results?
Thanks!
Hi Gustavo,
It's been a while, but I believe the information on this page may still be relevant:
So, if you're not on at least version 2.3 or if you are and this is still happening then you can try updating the connection or removing/re-inserting the layer.
-Earl
Hey Earl,
I'm using 2.4.1. This topic you linked is actually on my bookmark bar, and I already tried some solutions there, including clearing the cache and updating connections. I'm still struggling with adding/copying/removing layer stuff, but hopefully will made a functional code soon. Still, the tool and syntax is pretty straightforward, I wonder why it does not work.
Update: I created a model, exported to Arcpy, added it to a toolbox and then I run it. Code runs without any results.
If I run the model on ArcGIS Pro, the symbology is updated.