AnsweredAssumed Answered

AssertionError from UpdateLayer when symbology_only False

Question asked by StevenHas on Aug 29, 2012
Latest reply on Aug 29, 2012 by StevenHas
Hi,

My scenario is, I have several mxds with the same layers, different layouts, used for map templates. I updated the symbology and labeling details for a layer in one mxd and want to push it into the others.

Attempting the following workflow results in an AssertionError during arcpy.mapping.UpdateLayer()

1. save the new details as a layer file.
2. run this code


files = r'C:\Temp\Layouts'
newLyr = arcpy.mapping.Layer('H:\\GIS_LayerFiles\\WaterNetwork\\Hydrant.lyr')
layerLongName = 'Water Network\\Hydrant'
symbologyOnly = False

for r,d,f in os.walk(files):
    for fl in f:
        path = r+'\\' + fl
        if fl[-3:] =='mxd':
            print path
            mxd = arcpy.mapping.MapDocument(path)
            df = arcpy.mapping.ListDataFrames(mxd)

            layers = arcpy.mapping.ListLayers(mxd)

            for lyr in layers:
                if str(lyr.longName).startswith(layerLongName):
                    arcpy.mapping.UpdateLayer(df,lyr, newLyr, symbologyOnly)
                    print lyr.longName + " symbology updated."



I get the following error

Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\utils.py", line 181, in fn_
return fn(*args, **kw)
File "C:\Program Files\ArcGIS\Desktop10.0\arcpy\arcpy\mapping.py", line 1477, in UpdateLayer
assert isinstance(data_frame, DataFrame)
AssertionError

Symbology only works fine, but as mentioned I have labeling changes I want to include.

I'd much rather not update them all manually.

Outcomes