Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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})
share|improve this question

1 Answer 1

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)
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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