Quantcast
Channel: Forums - Python
Viewing all articles
Browse latest Browse all 2485

Labels Still Not Visible after setting lyr.labelClasses[0].showLabels = True

$
0
0
Thanks to an earlier reply today, I'm moving along on my script but have encountered another hiccup.

I've set "lyr.showLabels = True". After looking through some other threads, it looks like I also need to set labelClasses to "showLabels = True". The script runs with no errors but does not show the labels. When clicking on layer properties|Labels, it shows that the labelClasses[0].expression DID accept the StateWellNumber field. But the checkbox for showing labels is not checked.

Is this "par for the course"? Not a big deal (I can just go in and fill the checkbox), but it would be nice to see the labels come in as the script runs.

Thanks,

Jon Mulder



Code:

LayerFileLocation = "H:\Documents\GIS\HydstraData"
LayerName = "WellPoints.lyr"
##Define layer:
lyr = arcpy.mapping.Layer(os.path.join(LayerFileLocation,LayerName))
arcpy.AddMessage(lyr)
##Show labels for WellPoints.
lyr.supports("LABELCLASSES")
lyr.showLabels = True
lyr.labelClasses[0].expression =  "StateWellNumber"
lyr.labelClasses[0].showLabels = True
arcpy.RefreshActiveView()


Viewing all articles
Browse latest Browse all 2485

Trending Articles