0

I created a python tool on Pro with the following code, and manage to run it without any errors or warnings. However, I do not see any changes on my layer:

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 changed the last line to this, but no results

arcpy.ApplySymbologyFromLayer_management(layers2, ref_lyrx)

Is my code expected to work?

  • Are you running the script in ArcGIS Pro or as a stand-alone script? – Emil Brundage Sep 20 at 18:27
  • I created a script tool with that code. Forgot to mention, but the code works without any errors. – Gustavo Sep 20 at 18:33
2

After changing the layer symbology you need to save the project.

aprx.save ()

  • Thanks for your help. Its not that simple, I could only manage to make it work with the project closed (running the tool in a unrelated project). I hope that there is a more straightforward way to do it. – Gustavo Sep 20 at 19:22

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.