ArcPy Apply Symbology from Layer not working

6537
18
08-23-2018 01:12 PM
DanielMatranga
New Contributor III

When I try to import symbology via the Python command window, it appears to work, but instead, the symbology has NOT changed, and I get this message below within the Symbology pane. I actually have to remove the layer from the map entirely, and re-add it to the map in order to update the symbology at all.

18 Replies
BrianBulla
Occasional Contributor III

Hi Eric Anderson‌,

Do you know if there is also an issue running ApplySymbologyFromLayer in C# code like the following:

Map map = MapView.Active.Map;

                pBar.Minimum = 0;
                pBar.Maximum = map.Layers.Count;

                this.Cursor = Cursors.Wait;

                GPExecuteToolFlags flags = GPExecuteToolFlags.GPThread;

                foreach (Layer layer in map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
                {   
                    var gpresult = await Geoprocessing.ExecuteToolAsync("ApplySymbologyFromLayer_management", new string[] { layer.Name.ToString(), @"K:\DSM Shared\ArcMap Symbology\10.2 Schema\Editing Symbols\" + layer.Name.ToString() + ".lyr" }, null, null, flags);
                    pBar.Value = pBar.Value + 1;
                }
0 Kudos
EricAnderson17
Occasional Contributor

Hi Brian,

I have not heard of any issues with using the ApplySymbologyFromLayer tool within C# code, but if you'd like to log a case with our Technical Support team we can definitely help investigate this issue with you.

Best regards,

Eric

0 Kudos
BrianBulla
Occasional Contributor III

Hi Eric.  I will post on the ArcGIS Pro Forum first, and if that doesn't work out, then I'll submit a ticket.

Thanks,

LeandraGordon
Occasional Contributor II

Quick update to bug: The problem seems a little better in Pro 2.8.1 but still has major problems with some LYRX files (the one with the colour ramp doesn't work). But seriously if this is part of your standard mapping automation workflow I and you have a choice I would start looking at alternative products.

0 Kudos
AaronFerrari
New Contributor II

In 2.4, I am having an issue where, when I use the python code, it works and runs through all of the layouts in all maps, but the changes are only reflected in the "Active" map. Is this part of the same bug? 

RolandDuhaime
Occasional Contributor

I created an iterative model in model builder and the .lyrx symbology isn't being applied to the layer.  I can batch iterate the layers in my map but when I save and close the map... the updated symbology is not saved in the project.  When I save and then open the project, the symbology has reverted back to the symbols that appeared before the batch import. This is a bug.

The only way I am able to apply the .lyrx symbology for each of the many layers, is to import the .lyrx file for each layer... using this approach the symbology can be saved and the next time I open the project, it has been preserved.  I have to do this for many layers, so it isn't an ideal approach.

KoryKramer
Esri Community Moderator

It sounds like you're seeing BUG-000120906: The Apply Symbology From Layer and Make Feature Laye..  You could go there and click the Subscribe button.

LeandraGordon
Occasional Contributor II

I tried using ApplySymbologyFromLayer in model builder and can confirm it doesn't work in Pro 2.7 as a standalone model on existing layers.
The model seems to get confused on what is a Variable Name and what is a Variable Value:

1. Looks ok:

LeandraGordon_0-1613368775105.png

2. Looks ok

 

LeandraGordon_1-1613368852722.png

3. The Variable Name is now the Variable Value:

LeandraGordon_2-1613368923628.png

It doesn't work in a Python Toolbox either -> https://my.esri.com/#/support/bugs/BUG-000136115

 

0 Kudos
by Anonymous User
Not applicable

I was getting stuck on this too but was able to achieve essentially the same result by creating a custom style (rather than using a symbology layer) and then batch running Match Layer Symbology to a Style on the workspace.