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.

asked Feb 2, 2016 at 8:33

1 Answer 1

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>

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

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.