Select to view content in your preferred language

Update Layer Symbology

1007
2
06-18-2011 09:02 PM
jenniferstarbuck
Deactivated User
If I am working with an MXD that has multiple river layers and each layer has different symbology ex color, and line thickness. Is there a way to use python script to change all the river layers to have the same symbology. I want to be able to change all the layers symbology at the same time with out having to go into the properties of each layer and making the changes there.
Can I use a reference MXD with the symbology I want and through python use the reference layer to update the other layers symbology?
Tags (2)
0 Kudos
2 Replies
JasonScheirer
Esri Alum
Yes, by using UpdateLayer in arcpy.mapping with the symbology_only argument set to True.
0 Kudos
SarahBurns
Emerging Contributor
I am trying to do something similar and have followed the link posted above.
I am getting an error: Runtime error <type 'exceptions.IndexError'>: list index out of range

The code I am working on is trying to change the symbology  of one file, I actually need it to work on many files. Can someone help me with the code below to make this happen! Thanks

import arcpy
mxd = arcpy.mapping.MapDocument(r"D:\updatelayer\mxd1.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "FFDI_19900102", df)[0]
sourceLayer = arcpy.mapping.Layer(r"C:\Project\Data\FFDI_19900101.img.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)
mxd.saveACopy(r"D:\updatelayer\test.mxd")
0 Kudos