1

I cannot make the ApplySymbologyFromLayer_management work on ArcGIS Pro by any means. The following code runs smoothly but does not give any results:

import arcpy

aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.activeMap
layer = aprxMap.listLayers()[0]
symblayer = r"C:\referencelayer.lyrx"
arcpy.ApplySymbologyFromLayer_management(layers, symblayer)
aprx.save()

Any ideas?

0

To test this in ArcGIS Pro 2.5.0 I used a project with one map and one polygon layer in it.

  1. I opened the project and gave the layer a very bright color, which was easy to distinguish from its original, and used Share | Layer File to save C:\Temp\referencelayer.lyrx (I did not have permissions to save it as C:\referencelayer.lyrx)
  2. I closed the project without saving.
  3. I restarted ArcGIS Pro with the same project and saw that the layer had its original colour
  4. I opened the Python window and typed in these commands in this order.

aprx = arcpy.mp.ArcGISProject("CURRENT")
aprxMap = aprx.activeMap
layer = aprxMap.listLayers()[0]
symblayer = r"C:\Temp\referencelayer.lyrx"
arcpy.ApplySymbologyFromLayer_management(layer, symblayer)
  1. At this point the layer colour changed to be the very bright one obtained from the layer file.
  2. I then saved the project using ArcPy

aprx.save()
  1. I closed ArcGIS Pro and then re-opened the project.
  2. As expected the layer had the very bright colour.

I think the comment from @KHibma was probably correct in that the main difference between my code and yours is the attention I paid to using a variable named layer in two places rather than setting layer and then trying to retrieve a value from layers.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.