AnsweredAssumed Answered

ApplySymbologyFromLayer_management creates copy of a layer rather than updating it

Question asked by bauman312 on Jun 12, 2013
Latest reply on Jun 18, 2013 by bauman312
Hey all,

I'm very new to ArcPy, and have encountered a roadblock when trying to update a layer's symbology using ApplySymbologyFromLayer_management. It works, but it creates a copy of the target layer rather than updating it in place. In order to clean out the duplicates, I attempted to apply the RemoveLayer function to the original layer (as seen on the second to last line), but this did not seem to remove it from the TOC.

import arcpy from arcpy import analysis, env  workspace = arcpy.env.workspace = r"C:/temp"  arcpy.env.overwriteOutput = True  mxDoc = arcpy.mapping.MapDocument(r"X:/GisResources/Mxd Map Templates/HighUnemploymentCensusTracts_Template.mxd")  df = arcpy.mapping.ListDataFrames(mxDoc, "Detail Map") [0]  co_layer = arcpy.mapping.ListLayers(mxDoc,"",df) [0]  co_name = "NAME"  rows = arcpy.SearchCursor(co_layer)  for row in rows:     co = row.getValue(co_name)     whereClause = "NAME <> '%s'" % co     analysis.Select(co_layer, "Co_%s" % co, whereClause)     arcpy.ApplySymbologyFromLayer_management("Co_%s" % co, "Export_Output_21")     inputLayer = arcpy.mapping.Layer("Co_%s" % co)     arcpy.mapping.RemoveLayer(df, inputLayer)      arcpy.RefreshActiveView()