My goal is to generate any number of MXD files with custom class-break-values using a consistent, pre-defined style.

For example, in ArcMap (10.2.2 and 10.3.1), I have an MXD with a graduated-color layer that has a single class-break-value symbol in it. I want to update this layer's symbology from ArcPy using a .lyr file without affecting that class-break-value.

I can do this very easily from ArcMap: TOC > Layer Properties > Symbology > Import > Select the .lyr file > "Just the symbols" option > OK

Is there a way to mimick this from ArcPy?

First Attempt

When I try the following code (using the same .lyr file as above), the TOC layer's style is updated correctly, but its class-break-value is overwritten by the class-break-value from the .lyr file:

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
dataFrame = arcpy.mapping.ListDataFrames(mxd)[0]
sourceLayer = arcpy.mapping.Layer(pathToLyrFile)    
destLayer = arcpy.mapping.ListLayers(mxd, existingLayerName)[0]
arcpy.ApplySymbologyFromLayer_management(destLayer, sourceLayer)

Second Attempt

UpdateLayer has a symbol-only option, but it also overwrites the class-break-value:

arcpy.mapping.UpdateLayer(dataFrame, destLayer, sourceLayer, True)

Third Attempt

Originally, I tried importing the .lyr file into a blank MXD file after modifying the class-break-value, but when I change the value this way, the class-break's symbol is lost (and we are back to where we started):

import arcpy
mxd = arcpy.mapping.MapDocument(mxdPath)
dataFrame = arcpy.mapping.ListDataFrames(mxd)[0]
layer = arcpy.mapping.Layer(pathToLyrFile)
layer.symbology.classBreakValues = [0, 50]
arcpy.mapping.AddLayer(dataFrame, layer, 'TOP')

2 Answers 2


I have had better success replacing the data source on the layer than applying symbology to a new data set. Try saving your a copy of each of your class break options to a lyr file, add that lyr to your new map, then substitute the layer it is referencing using Layer.replaceDataSource. You can code the whole thing and reference a table of mxd's, lyr files and data source paths, then just let it crawl through the folder of mxd's. Assuming a limited number of class break options.

  • In my specific case, I won't know the class-break-values ahead of time, but your suggestion is a good option for anyone who does know them - thanks.
    – mcso
    Commented Jan 27, 2016 at 18:05

I was able to get this working by rewriting my script in ArcObjects by adding an ILayerFile to a blank MapDocument and then modifying its IClassBreaksRenderer.Break[n] values as needed (without losing the original symbol from the .lyr file).

If ArcObjects isn't an option for you and you know the class-break-values ahead of time, Mike's answer will be the better option for you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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