Hello,
I am looking to rearrange classes in a SINGLE layer using arcpy mp. Here's a visual sample only:
The documentation suggests LegendItems items is not settable (see image below) in basic arcpy.mp, although I did try and got an error suggesting the same.
So, I drilled into the CIM renderer groups , but can't quite get it working. The resulting map is void of symbology. Here's what I have so far.
# move Duplex legend/class to end
l_cim = lyr1.getDefinition('V2')
for grp in l_cim.renderer.groups:
for cls in grp.classes:
if cls.label == 'Duplex':
grp.classes = [x for x in grp.classes if x != cls] + [cls]
lyr1.setDefinition(l_cim)
Viewing the list grp.classes before and after shows the Duplex object moved to the end of the list, so I suppose there is more going on under the hood...or I'm missing something.
Bottom line is I'm looking to mimic/automate this GUI behavior from the symbology pane (or by right clicking a class > reorder (top, up, down, bottom). Any tips would be appreciated.
Tyler