Pro 2.0 Bug "Apply Symbology From Layer" GeoProcessing Tool

5229
22
Jump to solution
07-18-2017 02:52 PM
ThomasCox
Occasional Contributor

Applying symbology from a .lyr or .lyrx file has been an on-going battle for me.  I had an earlier post describing a problem with 1.4.  I was able to get past that, but now find a different problem at 2.0.

I am in the process of upgrading a couple of applications from 1.4 to 2.0  I have encountered a problem when I attempt to apply the symbology of a .lyr or .lyrx file to a layer brought into the session by the application.  This had been working in 1.4

I wanted to see how Pro itself handled this by running the GeoProcessing Tool "Apply Symbology From Layer" interactively through native Pro.  I manually brought in a non symbolized grid layer into Pro.  I ran the tool and entered the grid layer as the input layer.  For the Symbology layer, I navigated to a .lyrx file that is built from a different but identically structured grid.  As soon as I finished browsing to this file and selected it, the "ApplySymbology From Layer" tool 'seized up'.

Regarding the .lyrx file.  I am able to add it directly to a pro-session with no problems and proper symbolization.  If I do this, I am able to run the Apply Symboloby From Layer tool interactively, using the just added grid (from the .lyrx) file as the symbol layer and the tool works. It appears the version 2.0 tool only works with fully qualified layers that have been added to the session and not with providing it .lyr or .lyrx files that point to and are symbolized the same way. 

I have a series of screen captures illustrating this experience with using the tool with a .lyrx file and then with a layer already added to Pro.

This image shows a non symbolized grid file added to Pro

non symbolized raster

This image shows trying to run the tool using a .lyrx file as the symbology layer source.  This image also shows the output screen from Visual Studio that captures how it behaved after adding the .lyrx file to the Symbology Layer input:

It simply seizes up.

As a test to make sure the .lyrx file I was using was healthy, I added it to the Pro session through the Add Data button. This image shows it successfully added:

The following image shows running the Apply Symboloby From Layer tool using the just added GRID from the .lyrx file. When I populate the Symbology Layer input, the tool does not misbehave:

The final image shows the initial non-symbolized grid now with the proper symbology.

This seems to confirm that the tool is not properly handling .lyrx files when provided as a the symbology source.

Any assistance is appreciated.  I will be unable to reply to any responses for a few days.

Thanks again.

0 Kudos
22 Replies
cweirpatrickco
New Contributor II

Ditto. My script tool returns no errors but the .lyrx symbology isn't reflected on my layers. Have tried closing and re-opening my project to no avail. Any new workarounds for this??

0 Kudos
ChristineDartiguenave
Esri Contributor

The issue has been fixed with the SDK only. The developers are aware that it is not working in Python and are looking into it. In my case, I had a simple point symbol to assign and the following steps managed to assign the symbology to my new layer:

  1. Add the lyrx file to the map: m.addDataFromPath(mysymbologylayerxpath)
  2. Get the layer's symbology: mysymbology=m.listLayers()[0].symbology
  3. Remove the layer from the map: m.removeLayer(m.listLayers()[0])
  4. Assign the symbology to my new layer in the map: new_layer.symbology=mysymbology

They are ways to update some of the symbology properties as well if needed. I did not need to in my case. I hope this helps until the issue gets resolved.

Christine Dartiguenave

Esri Water Resources Team 

0 Kudos
williamwinner
New Contributor III

I was trying to find the answer for python because the arcpy.management.ApplySymbologyFromLayer tool was not working for me.

I wanted to pass along the workaround that I found as it might help people.  This bit of code worked for me:

#Get the layer from the map
lyr = myMap.listLayers(SymLayers[n])[i]

#Get the layer file on disk
lyrFile = arcpy.mp.LayerFile(LayerPath + SymLayers[n] + '.lyrx')

#Set the map layer's symbology to the layer file on disk's symbology
lyr.symbology =lyrFile.listLayers()[0].symbology