AnsweredAssumed Answered

Edit legend label or description with python

Question asked by taylor65 on Mar 19, 2013
Latest reply on Mar 22, 2013 by jbarrette-esristaff

In a nut shell, If anyone knows how to change the text in legend labels in arcpy let me know.

This is what I have tried so far...

I am trying to edit the description of the layer using the layer.description method and then setting the legend item's style to one that uses the description as the primary legend label.

I can set the style property and when I print the layer's description to the terminal it appears to be set, however when I open the mxd, the description isn't filled out (under the symbology tab of the layer's properties).

Here's a sample of my code

for item in mxdlist:     if ".mxd" in item:         figpath = path + item         mxd = arcpy.mapping.MapDocument(figpath)         for item in arcpy.mapping.ListLayers(mxd):             if "RIPRAP" in                 item.description = 'Rip Rap'                 print "....Updated"                 print item.description         legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "Legend")[0]         legendlayers = legend.listLegendItemLayers()         for item in legendlayers:             if "RIPRAP" in                 style = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items","blobDesc")[0]                 legend.updateItem(item, style)                 print     del mxd

I think that the layer property for description isn't what I think it is, but maybe somebody else knows what I am missing.

Thanks in advance!