I´m trying to label features of a dataset using ArcPy and the lblclass function.
While commands like "VBNewline" and "Round" work pretty well, I´m not able to change colors or font style. An expression that works in ArcMap doesn´t work in the script.
Could anyone help me out please?
I´m using ArcGIS 10.0
Code that works:
#Adding Labels
layer = arcpy.mapping.ListLayers(mxd, "")[0]
if layer.supports("LABELCLASSES"):
for lblclass in layer.labelClasses:
lblclass.className = "Flaeche"
lblclass.expression = "[FID] & VBNewLine & Round([AREA_mm2],2)"
lblclass.showClassLabels = True
layer.showLabels = True
arcpy.RefreshActiveView()
Code that works in ArcMap but not in ArcPy
#Adding Labels
layer = arcpy.mapping.ListLayers(mxd, "")[0]
if layer.supports("LABELCLASSES"):
for lblclass in layer.labelClasses:
lblclass.className = "Flaeche"
lblclass.expression = ""<CLR red='255' green='0' blue='0'>" & [FID] & VBNewLine & Round([AREA_mm2],2) & "</CLR>""
lblclass.showClassLabels = True
layer.showLabels = True
arcpy.RefreshActiveView()
Best Answer
This code doesn't work because Python interpreter doesn't understand two double quotes in a row.
Instead you can try this: