<?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 Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265334#M67025</link>
    <description>&lt;P&gt;do you close the symbology tab before running the script and reopen it after?&lt;/P&gt;</description>
    <pubDate>Wed, 08 Mar 2023 03:23:37 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2023-03-08T03:23:37Z</dc:date>
    <item>
      <title>CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265290#M67015</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wrote a Python script that reads some maps that already have&lt;EM&gt; "GraduatedColorsRenderer&lt;/EM&gt;" with 8 breaks&amp;nbsp;for&amp;nbsp;symbology.&lt;/P&gt;&lt;P&gt;The script is supposed to use &lt;STRONG&gt;CIM &lt;/STRONG&gt;definitions&amp;nbsp;to change &lt;EM&gt;&lt;STRONG&gt;Legends Label formatting&lt;/STRONG&gt; to&amp;nbsp;&lt;STRONG&gt;Percentage&lt;/STRONG&gt; with &lt;STRONG&gt;1 decimal poin&lt;/STRONG&gt;&lt;/EM&gt;&lt;STRONG&gt;t&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;The script runs without any errors but&lt;STRONG&gt; when you check the layer, the changes are not applied visually&lt;/STRONG&gt;. Although when you check the "&lt;EM&gt;Advanced symbology&lt;/EM&gt;" pane, it shows that the changes are there. (Also after running the script, if you call components in "l_cim.renderer.numberFormat" it shows the changes are made.&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you &lt;STRONG&gt;&lt;U&gt;&lt;EM&gt;manually&lt;/EM&gt;&lt;/U&gt; &lt;/STRONG&gt;&lt;EM&gt;"refresh values&lt;/EM&gt;" in "&lt;EM&gt;primary symbology&lt;/EM&gt;" pane or change the decimal point or check thousand separator checkbox in "&lt;EM&gt;Advanced symbology&lt;/EM&gt;" pane, &lt;STRONG&gt;suddenly all the changes from before applies to the labels&lt;/STRONG&gt;. &lt;FONT size="2"&gt;&lt;STRONG&gt;(See the Screenshots and Script below)&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#800000"&gt;Question 1)&lt;/FONT&gt; Is there any refresh method I should use or that's just a bug?&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#800000"&gt;Question 2) &lt;FONT color="#000000"&gt;How to change the option to Number represented as fractions (using python)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;U&gt;Here is an example of the issue:&amp;nbsp;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Before Running the Script:&amp;nbsp;&lt;BR /&gt;&lt;/STRONG&gt;(Actual legend on the left and the formatting setting on the right)&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Before Running Code.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64633i431827F22CD137FB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Before Running Code.png" alt="Before Running Code.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;After Running the Script:&lt;BR /&gt;&lt;/STRONG&gt;Category and decimal places changed on the right,&lt;BR /&gt;but the actual labels are the same as before&lt;BR /&gt;&lt;STRONG&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="After Running Code.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64635i710CB78E53C10DCC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="After Running Code.png" alt="After Running Code.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;After Changing Decimal places to 2:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="After_manually_changing_decimal.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/64636iF7EE62923ECB4CF9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="After_manually_changing_decimal.png" alt="After_manually_changing_decimal.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Here is the python Script:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
aprx = arcpy.mp.ArcGISProject("CURRENT")
#list of current map names
map_list = ['map_cityA', 'map_cityB', 'map_cityC' ]

# set symbology for each map 
for map_name in map_list:
    mp = aprx.listMaps(map_name)[0]
    for lyr in mp.listLayers():
        if lyr.isFeatureLayer: 
                l_cim = lyr.getDefinition('V3')
                # create an empty empty numeric object for percentage
                num_obj = arcpy.cim.CreateCIMObjectFromClassName('CIMPercentageFormat', 'V3')
                num_obj.alignmentOption = 'esriAlignLeft'
                num_obj.alignmentWidth = 12
                num_obj.roundingOption = 'esriRoundNumberOfDecimals'
                num_obj.roundingValue = 1  # decimal places to show 
                num_obj.zeroPad = False
#                 num_obj.useSeparator = False
                num_obj.showPlusSign=False
                
                # assign the new numeric object to the renderer's number format
                l_cim.renderer.numberFormat = num_obj 
                lyr.setDefinition(l_cim) #set the CIM 
                
                # tried to force it to refresh (did not work)
                l_cim = lyr.getDefinition('V3')
                lyr.setDefinition(l_cim)

#save project after
aprx.save()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT size="2"&gt;My platform: Windows 11 (22H2) and&amp;nbsp; ArcGISPro 3.1.0&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 01:32:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265290#M67015</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-03-08T01:32:02Z</dc:date>
    </item>
    <item>
      <title>Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265334#M67025</link>
      <description>&lt;P&gt;do you close the symbology tab before running the script and reopen it after?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 03:23:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265334#M67025</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T03:23:37Z</dc:date>
    </item>
    <item>
      <title>Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265337#M67027</link>
      <description>&lt;P&gt;Yes, I only kept the script open and all the maps and layouts were closed while running it. After seeing your comment I made sure that the empty symbology tab is closed as well, but that made no difference.&lt;/P&gt;&lt;P&gt;I also kept one of the maps open to see if that changes anything and it did not.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I forgot to mention that I also run&amp;nbsp;&lt;STRONG&gt;l_cim.renderer.heading = 'A new Heading'&lt;/STRONG&gt; in the same loop and that &lt;STRONG&gt;immediately works&lt;/STRONG&gt; and changes the symbology heading but the legends labels (as mentioned in the main post) don't change!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 04:24:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265337#M67027</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-03-08T04:24:54Z</dc:date>
    </item>
    <item>
      <title>Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265427#M67031</link>
      <description>&lt;P&gt;I don't think lines 27 and 28 will force a refresh, so you may as well get rid of those.&amp;nbsp; and don't keep any maps open to see if it changes anything, open it after, and if that does nothing, save the project, close it and reopen it to see if the changes persisted... I am not convinced that the project is being saved if it is open and the script isn't being run outside of an open project&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 13:35:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265427#M67031</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-03-08T13:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265475#M67032</link>
      <description>&lt;P&gt;Thank you for the comment Dan. I got the idea of Force refresh (lines 27 and 28) from Example 2 and 3 of&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/arcpy/mapping/python-cim-access.htm" target="_blank" rel="noopener"&gt;this documentation&lt;/A&gt;, although that was for Layout, I thought it might work on the layers as well. So if that doesn't apply here I will exclude that.&lt;/P&gt;&lt;P&gt;Yeah, I normally don't open any maps before running the script .&amp;nbsp;I did otherwise once just to test.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also put&amp;nbsp;aprx.save() inside the loop to save project after changing each map and that did not fix it. Closing and opening the project also did not fix it.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The part that I still don't get is when I put&amp;nbsp; &lt;U&gt;&lt;EM&gt;l_cim.renderer.heading = 'A new Heading&lt;/EM&gt;&lt;/U&gt;&lt;EM&gt;'&amp;nbsp;&lt;/EM&gt; into line 11 or 24 of the script (before or after changing the labels) the heading gets changed immediately even if the map is open! They are both under&amp;nbsp;l_cim.renderer and why are they showing these different behaviors?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Mar 2023 15:16:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1265475#M67032</guid>
      <dc:creator>Mahdi_Ch</dc:creator>
      <dc:date>2023-03-08T15:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: CIM Symbology Number Formats Change Doesn't Reflect - Bug or Feature?</title>
      <link>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1510552#M71126</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/662373"&gt;@Mahdi_Ch&lt;/a&gt;&amp;nbsp;did you ever find a solution to this?&amp;nbsp; I'm having the same issue&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jul 2024 11:29:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/cim-symbology-number-formats-change-doesn-t/m-p/1510552#M71126</guid>
      <dc:creator>Lee_Butler</dc:creator>
      <dc:date>2024-07-26T11:29:54Z</dc:date>
    </item>
  </channel>
</rss>

