Select to view content in your preferred language

How to Update Font And Color Of a Label in ArcMap Using ArcPy

1100
2
10-23-2018 02:32 PM
BruceGreen
Occasional Contributor

I am adding a layer to map docyment through and stand alone ArcPy snippet like this

MXD = arcpy.mapping.MapDocument(r"C:\\arcgis\\ArcTutor\\AAA\\MXDs\\map.mxd")
df = arcpy.mapping.ListDataFrames(MXD)[0]
print('Step 3')
layer = arcpy.mapping.Layer("Primary")
layer.minScale = 10000
layer.showLabels = True
arcpy.mapping.AddLayer(df, layer, "AUTO_ARRANGE")

Can you please let me know how I can change the label font two 14 and color to red using ArcPy?

0 Kudos
2 Replies
curtvprice
MVP Esteemed Contributor

Sorry, but this kind of granular control of symbology is not supported in arcpy. The way to do this is to use ArcMap to set up the symbology and labeling you want, and save it as a .lyr file.

Then in your script use arcpy.mapping.Layer() to load the layer in, and use the replaceDataSource method to set the layer to use your data. 

BruceGreen
Occasional Contributor

Thanks but labeling is not adding to .lyr ! 

I created a layer from map document it is applying the symbology but not enable and apply Labeling setting in new layer

0 Kudos