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.

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>

  • Thank you! That expression worked for font size. What about layer symbology? Don't you know hot to set it? – david_p Feb 2 '16 at 8:59
  • 1
    Sorry I didn't see you had two questions - please ask this as a separate question. – Midavalo Feb 2 '16 at 17:46
  • OK, I ask new question here: gis.stackexchange.com/questions/179139/… – david_p Feb 2 '16 at 19:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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