matoretta

Update Layer without SaveACopy document

Discussion created by matoretta on Aug 23, 2011
Latest reply on Aug 24, 2011 by SWendel-esristaff
Hi i want change symbology using .lyr file all my raster layers in Group Layer. I use This piece of Code: and nothing happen until i save a copy of Document.. in copy i have new symbology in all layers in grouplayer, but how to do it without save a copy..in current Document? thanks.

import arcpy
mxd = arcpy.mapping.MapDocument("g:\\symb.mxd")
GroupLayer = "mm"
sourceLayer = arcpy.mapping.Layer("g:\\raster.lyr")
df = arcpy.mapping.ListDataFrames(mxd)[0]

for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.isRasterLayer:
x=lyr.longName
if x.find(GroupLayer +"\\") ==0 :
arcpy.mapping.UpdateLayer(df, lyr, sourceLayer, True)


arcpy.RefreshActiveView()
arcpy.RefreshTOC()
mxd.saveACopy(r"C:\Project2.mxd")
del mxd, sourceLayer

Outcomes