Turn on label with arcpy to create script tool

334
1
06-23-2022 01:33 AM
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
1 Reply
DuncanHornby
MVP Notable Contributor

You need to read the help file and understand how to turn your script into a script tool. Its all in the help file here.

0 Kudos