Skip to main content
Made title better match question
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

Why won't ArcPy label properlyLabel Class object returning unexpected value for expression property?

minor clean up of text; formatting
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
...     if lyr.supports("LABELCLASSES"):
...         for lblclass in lyr.labelClasses:            
...             lblclass.expression = " [OBJECTID]"
...             if lblClass.showClassLabels:
...                     print "    Class Name:  " + lblClass.className
...                     print "    Expression:  " + lblClass.expression
... mxd.save()
... del mxd
... 

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?

import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
...     if lyr.supports("LABELCLASSES"):
...         for lblclass in lyr.labelClasses:            
...             lblclass.expression = " [OBJECTID]"
...             if lblClass.showClassLabels:
...                     print "    Class Name:  " + lblClass.className
...                     print "    Expression:  " + lblClass.expression
... mxd.save()
... del mxd
... 

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?

import arcpy
mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
    if lyr.supports("LABELCLASSES"):
        for lblclass in lyr.labelClasses:            
            lblclass.expression = " [OBJECTID]"
            if lblClass.showClassLabels:
                    print "    Class Name:  " + lblClass.className
                    print "    Expression:  " + lblClass.expression
mxd.save()
del mxd

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?

Why won't ArcpyArcPy label properly

import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
...     if lyr.supports("LABELCLASSES"):
...         for lblclass in lyr.labelClasses:            
...             lblclass.expression = " [OBJECTID]"
...             if lblClass.showClassLabels:
...                     print "    Class Name:  " + lblClass.className
...                     print "    Expression:  " + lblClass.expression
... mxd.save()
... del mxd
... 

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?!?

Why won't Arcpy label properly

import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
...     if lyr.supports("LABELCLASSES"):
...         for lblclass in lyr.labelClasses:            
...             lblclass.expression = " [OBJECTID]"
...             if lblClass.showClassLabels:
...                     print "    Class Name:  " + lblClass.className
...                     print "    Expression:  " + lblClass.expression
... mxd.save()
... del mxd
... 

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?!?

Why won't ArcPy label properly

import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... for lyr in arcpy.mapping.ListLayers(mxd, "TestFile_LineToPoints13_Prod"):
...     if lyr.supports("LABELCLASSES"):
...         for lblclass in lyr.labelClasses:            
...             lblclass.expression = " [OBJECTID]"
...             if lblClass.showClassLabels:
...                     print "    Class Name:  " + lblClass.className
...                     print "    Expression:  " + lblClass.expression
... mxd.save()
... del mxd
... 

Prints:

Class Name: Default

Expression: [Shape_Length]

The label for that layer is even set at ObjectID and is currently showing the labels... Why does it keep responding Shape_Length?

Formatting
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
Loading
Source Link
Numus
  • 81
  • 1
  • 6
Loading