I am trying to work out if it is possible to create a script for ArcGIS Pro that allows me to turn on labels for a feature, and then lets me control:
-halo on / off
Ideally the script would have user-defined inputs for all of the above.
It seems that this may be possible in ArcMap, but I can't seem to find any discussion for ArcGIS Pro. Can anyone point me to documentation, code samples or a tutorials that might get me started?
I was thinking something along the lines of the following code might work, but it only seems to affect the halo width, all other properties are unchanged:
featurename = arcpy.GetParameterAsText(0)
labelcolumn = str(arcpy.GetParameterAsText(1))
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.activeMap
for lyr in m.listLayers(featurename):
lblClass = lyr.listLabelClasses()
lblClass.expression = "[" + labelcolumn + "]"
# Get the layer's CIM definition
l_cim = lyr.getDefinition('V2')
# Get first label class
lc = l_cim.labelClasses
# Set label class symbol properties
lc.textSymbol.symbol.color = 'white'
lc.textSymbol.symbol.font = 8
lc.textSymbol.symbol.haloColor = 'black'
lc.textSymbol.symbol.haloSize = 1
# Set layer's CIM definition
# Show labels
lyr.showLabels = True