ApplySymbologyFromLayer on ArcGIS Pro does not work

170
3
09-17-2019 08:52 AM
Highlighted
New Contributor III

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:

workspace = "C:\whatever.gdb"
arcpy.env.workspace = workspace
ref_lyrx = r"C:\SimbologyIwant.lyrx"
aprx = arcpy.mp.ArcGISProject("CURRENT")
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!

Reply
0 Kudos
3 Replies
Highlighted
Occasional Contributor III

Hi Gustavo,

It's been a while, but I believe the information on this page may still be relevant:

https://community.esri.com/thread/216481-adding-feature-class-and-applying-symbology-in-arcgis-pro-u... 

  • The problem was fixed at version 2.3 and I don't observe it at 2.4

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

Reply
0 Kudos
Highlighted
New Contributor III

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.

Reply
0 Kudos
Highlighted
New Contributor III

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.

Reply
0 Kudos