#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()
#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()
Solved! Go to Solution.
This code doesn't work because Python interpreter doesn't understand two double quotes in a row.
Instead you can try this:lblclass.expression = '"%s" & [FID] & VBNewLine & Round([AREA_mm2],2) & "%s"' % ("<CLR red='255' green='0' blue='0'>", "</CLR>")
This code doesn't work because Python interpreter doesn't understand two double quotes in a row.
Instead you can try this:lblclass.expression = '"%s" & [FID] & VBNewLine & Round([AREA_mm2],2) & "%s"' % ("<CLR red='255' green='0' blue='0'>", "</CLR>")