<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic UniqueValueRenderer re-arrange classes in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-re-arrange-classes/m-p/1354295#M69305</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am looking to rearrange classes in a SINGLE layer using arcpy mp.&amp;nbsp; Here's a visual sample only:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701201278480.png" style="width: 193px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87339i9E2BA65424477143/image-dimensions/193x130?v=v2" width="193" height="130" role="button" title="TylerT_0-1701201278480.png" alt="TylerT_0-1701201278480.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701203234568.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87345i070856423BD39F6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_0-1701203234568.png" alt="TylerT_0-1701203234568.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701203168633.png" style="width: 579px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87344i5F92B920689674DE/image-dimensions/579x85?v=v2" width="579" height="85" role="button" title="TylerT_0-1701203168633.png" alt="TylerT_0-1701203168633.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, I drilled into the CIM renderer groups , but can't quite get it working.&amp;nbsp; The resulting map is void of symbology.&amp;nbsp; Here's what I have so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# 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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Bottom line is I'm looking to mimic/automate this GUI behavior from the symbology pane (or by right clicking a class &amp;gt; reorder (top, up, down, bottom).&amp;nbsp;&amp;nbsp;Any tips would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_2-1701203735909.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87349iE2F7EA6F8F85376E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_2-1701203735909.png" alt="TylerT_2-1701203735909.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Tyler&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2023 20:37:10 GMT</pubDate>
    <dc:creator>TylerT</dc:creator>
    <dc:date>2023-11-28T20:37:10Z</dc:date>
    <item>
      <title>UniqueValueRenderer re-arrange classes</title>
      <link>https://community.esri.com/t5/python-questions/uniquevaluerenderer-re-arrange-classes/m-p/1354295#M69305</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am looking to rearrange classes in a SINGLE layer using arcpy mp.&amp;nbsp; Here's a visual sample only:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701201278480.png" style="width: 193px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87339i9E2BA65424477143/image-dimensions/193x130?v=v2" width="193" height="130" role="button" title="TylerT_0-1701201278480.png" alt="TylerT_0-1701201278480.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701203234568.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87345i070856423BD39F6D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_0-1701203234568.png" alt="TylerT_0-1701203234568.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_0-1701203168633.png" style="width: 579px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87344i5F92B920689674DE/image-dimensions/579x85?v=v2" width="579" height="85" role="button" title="TylerT_0-1701203168633.png" alt="TylerT_0-1701203168633.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;So, I drilled into the CIM renderer groups , but can't quite get it working.&amp;nbsp; The resulting map is void of symbology.&amp;nbsp; Here's what I have so far.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# 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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;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.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Bottom line is I'm looking to mimic/automate this GUI behavior from the symbology pane (or by right clicking a class &amp;gt; reorder (top, up, down, bottom).&amp;nbsp;&amp;nbsp;Any tips would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="TylerT_2-1701203735909.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/87349iE2F7EA6F8F85376E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="TylerT_2-1701203735909.png" alt="TylerT_2-1701203735909.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Tyler&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 20:37:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/uniquevaluerenderer-re-arrange-classes/m-p/1354295#M69305</guid>
      <dc:creator>TylerT</dc:creator>
      <dc:date>2023-11-28T20:37:10Z</dc:date>
    </item>
  </channel>
</rss>

