AnsweredAssumed Answered

UpdateLayer does not preserve grouped values in TOC?

Question asked by kalley on Sep 14, 2012
Latest reply on Sep 18, 2012 by kalley
I am trying to update layer symbology in multiple mxd's using ArcGIS 10.0 and the script below.  Everything works as desired except for two issues:

1. Unlike in the .lyr file that I'm using to update my mxd layers, the updated layer lists each value and its symbol independently in the TOC instead of preserving symbology groups.  The grouping is required for legend formatting, because 8 symbols are used to represent about 25 values.
2. The updated layer expands to reveal symbology in the TOC (a nuisance, but acceptable)

Neither of these problems occur if I manually bring the .lyr into an mxd file.  From reading other posts, I gather that updated layers should preserve the appearance of the source layer in the TOC.  Is that a misunderstanding?  In my experience, updated layers always appear in the TOC with the new symbology expanded.  Is arcpy capable of preserving grouped symbology?

import arcpy, os folderPath = r"V:\Projects\Shared\Mapping\HighwayMappingSystem\HMS_30\working" endswith_Text = "- copy.mxd"  SL = arcpy.mapping.Layer(r"V:\Projects\Shared\Mapping\HighwayMappingSystem\HMS_30\working\HIGHWAYS_fix.lyr") for filename in os.listdir(folderPath):     fullpath = os.path.join(folderPath,filename)     if filename.lower().endswith(endswith_Text):             mxd = arcpy.mapping.MapDocument(fullpath)             dfList = arcpy.mapping.ListDataFrames(mxd)             for df in dfList:                 layers = arcpy.mapping.ListLayers (mxd,"HIGHWAYS",df)                 if layers:                     for lyr in layers:                         arcpy.mapping.UpdateLayer(df,lyr,SL,True)    ()

Kerry Alley
Mapping Unit
VT Agency of Transportation