wheelejp

Exported PDF failing to reflect showClassLabels = False

Discussion created by wheelejp on Jan 21, 2014
Hi,

I'm having trouble getting my exported .pdf and saved .mxd to show that my labels have been turned off using the LabelClass object. The code works fine when run from the python window in ArcMap and I can even get my AddMessages to print out exactly how the layer should behave, but the mxd and pdf do not reflect the changes. Hopefully I posted the code correctly and this makes sense. I'm happy to explain further and thanks for any help!


for lyr in arcpy.mapping.ListLayers(mxd)[3:11]:
    if lyr.name not in visible_layers: # visible_layers is a list of layer names(strings) supplied by the user
      ##lyr.visible = True
  ##else:       
        lyr.visible = False # if .lyr in mxd was NOT supplied by the user, turn the layer off       
        for lbl in lbl_layer.labelClasses: # lbl_layer is a .lyr supplying labels for visible_layers,           
        # lbl_layer contains seperate label classes matching lyr.name layers, including sql queries                 
            if lyr.name == lbl.className: # if .lyr is NOT visible locate the matching label class name
                arcpy.AddMessage("lyr.name: " + lyr.name)
                arcpy.AddMessage("lbl.className: " + lbl.className)
                lbl.showClassLabels = False # turn labels OFF for the label class name matching the .lyr
                arcpy.RefreshActiveView()
                arcpy.AddMessage("lbl.className ON: " + str(lbl.showClassLabels))

Outcomes