2

I have some ArcMap addin that creates new layer and add it into table of content. I need to set up labels for that layer.

I have made some script for labeling layer:

mxd = arcpy.mapping.MapDocument("CURRENT")
data_frame = mxd.activeDataFrame

layer_divide = arcpy.mapping.ListLayers(mxd, "layer", data_frame)[0]
if layer_divide.supports("LABELCLASSES"):
    for lblclass in layer_divide.labelClasses:
        lblclass.expression = "[OBJECTID]"
        lblclass.showClassLabels = True

layer_divide.showLabels = True
arcpy.RefreshActiveView()

This add labels, but I don't know how to change font size of that labels.

david_p
  • 1,783
  • 1
  • 19
  • 34

1 Answers1

4

Labels in ArcMap can have formatting codes within the expression, so something like:

lblclass.expression = '"{}" + [OBJECTID] +  "{}"'.format("<FNT size = '24'>","</FNT>") 

might work for you. This is adding font tags around your ObjectID into a label expression <FNT size = '24'> + OBJECTID + </FNT>

Midavalo
  • 29,696
  • 10
  • 48
  • 104
  • Thank you! That expression worked for font size. What about layer symbology? Don't you know hot to set it? – david_p Feb 02 '16 at 08:59
  • 1
    Sorry I didn't see you had two questions - please ask this as a separate question. – Midavalo Feb 02 '16 at 17:46
  • OK, I ask new question here: http://gis.stackexchange.com/questions/179139/create-symbology-for-new-layer-using-python-arcpy-mapping – david_p Feb 02 '16 at 19:59