I'm trying to use python to assign properties to a label class to a layer in my map in ArcGIS Pro 2.2.1, and no matter what I do, the changed properties do not appear when I examine the Label Class in the map. Below is an example of my code:
aprx = arcpy.mp.ArcGISProject(r"C:\Users\maxwell.reis\Desktop\USACE\Working_Map\Working_Map.aprx")
m = aprx.listMaps("Map")
lyr = m.listLayers("TEMP_lyr")
lblClass = lyr.listLabelClasses("Class 1")
lblClass.expression = "$feature.PARNAME"
The first print line correctly displays the label class expression of the layer in the map, and the second print line shows that the expression has successfully changed. However, when I go into the map to view the label class properties, nothing has changed.
Am I missing a step in the process? Is there another statement I need to make in python to get the map to recognize the updated Label Class Properties?
Solved! Go to Solution.
As a test can you try a Save As to a new aprx file name and see if the label class properties change there? Not an ideal solution if this works due to the structure of Pro where each aprx is tied to a file gdb so this solution could get messy.