Turn on label with arcpy to create script tool

56
0
2 weeks ago
Labels (3)
AlexandruBârsan
New Contributor

Hi! I want to create a script tool that will start the label for certain layers, that is to add the parameters with the layer to which I want to activate the label and what field I want to display it that I need.. I used this script

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 = " [Layer]"
layer.showLabels = True
arcpy.RefreshActiveView()

but it doesn't work to create a script tool, it only works in python windows. Do you have any suggestions?

Tags (3)
0 Kudos
0 Replies