2

I am attempting to automate symbology using python, and ArcMap 10.0. I am importing this script into a toolbox, which I run from arcmap

Currently I am getting two errors:

1) LayerObject: Set attribute renderer does not exist. I am not sure what the problem is.

2) When I change true to false, Could not find replacement layer.

Here is my code:

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd)[0]

updateLayer = arcpy.mapping.ListLayers(mxd, "*", df)[0]

sourceLayer = arcpy.mapping.Layer(r"C:\me\fun.lyr")


for lyr in updateLayer:

    arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)

#UpdateLayer ( data_frame, update_layer, source_layer, {symbology_only})
2

Had help from a co-worker who solved the problem.

I was trying to update a list of layers instead of a single layer file in my for loop.

Here's the solution.

import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd)[0]

updateLayer = arcpy.mapping.ListLayers(mxd, "*", df)

sourceLayer = arcpy.mapping.Layer(r"C:\me\fun.lyr")


for lyr in updateLayer:

    arcpy.mapping.UpdateLayer(df, lyr, sourceLayer)

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.