import arcpy mxd = arcpy.mapping.MapDocument(r"C:\path\to\my.mxd") for lyr in arcpy.mapping.ListLayers(mxd): if lyr.description == "Layer Name": lyr.showLabels = True del mxd arcpy.RefreshTOC() arcpy.RefreshActiveView()
Solved! Go to Solution.
mxd = arcpy.mapping.MapDocument('current')mxd = arcpy.mapping.MapDocument('current')If you want to see the result of scripts run in the Python Window in ArcMap reflected in the current map, reference the map document like this:mxd = arcpy.mapping.MapDocument('current')
That should do what you want.
import arcpy
... mxd = arcpy.mapping.MapDocument("CURRENT")
... layer = arcpy.mapping.ListLayers(mxd, "")[0]
... if layer.supports("LABELCLASSES"):
... for lblclass in layer.labelClasses:
... lblclass.showClassLabels = True
... lblclass.expression = " [PARCELID]"
... layer.showLabels = True
... arcpy.RefreshActiveView()