Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

This question already has an answer here:

In ArcGIS 10.1, I have a shapefile/layer with labels displayed on a map. Can I modify any of the formatting of the labels using Arcpy? Either directly in code or by importing style from another layer or the style manager would be fine. Specifically I want to add a halo around the text.

I have tried using arcpy.mapping.UpdateLayer with a source layer that has the label style that I want, but the only options are to update everything (including changing the source data, which I don't want) and to change symbology only (which doesn't cover the label style). Any way around this? Or another solution?

share|improve this question
add comment

marked as duplicate by PolyGeo, BradHards, iant Jun 18 '13 at 11:53

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

i think StyleItem (arcpy.mapping) can help you to solve your problem. it is reference of ListLayoutElements function.

Summary

Provides access to StyleItem class properties.

from the arcgis help document:

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyrFile = arcpy.mapping.Layer(r"C:\Project\Data\Rivers.lyr")
arcpy.mapping.AddLayer(df, lyrFile, "TOP")
styleItem = arcpy.mapping.ListStyleItems("USER_STYLE", "Legend Items", "NewDefaultLegendStyle")[0]
legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]
legend.updateItem(lyrFile, styleItem)

del mxd

i hope it helps you...

share|improve this answer
    
I think StyleItem was put in to be able to manipulate legend items rather that layer properties, so I don't think this will work - but I hope I am wrong –  PolyGeo Jul 25 '12 at 8:01
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.