<?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: 10.1: problem with lyr.symbology.addAllValues() in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754841#M58225</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a problem with .addAllValues() or are you looking for a way to add only some values.&amp;nbsp; Because .addAllValues adds ALL values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may want to try working with layer files that contain the unique set of values you are interested in.&amp;nbsp;&amp;nbsp; You could add the layer and it would be possible to change the data source on the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 30 Apr 2012 16:15:27 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2012-04-30T16:15:27Z</dc:date>
    <item>
      <title>10.1: problem with lyr.symbology.addAllValues()</title>
      <link>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754840#M58224</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have template lyrs("UNIQUE_VALUES") for my projects and need to limit values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
mxd = arcpy.mapping.MapDocument("CURRENT")
lyr = arcpy.mapping.ListLayers(mxd, "lyr")
lyr.symbology.addAllValues()
&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After that arcpy shuffle my values. How to limit legend correctly?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 29 Apr 2012 07:58:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754840#M58224</guid>
      <dc:creator>LeonidEliseev</dc:creator>
      <dc:date>2012-04-29T07:58:34Z</dc:date>
    </item>
    <item>
      <title>Re: 10.1: problem with lyr.symbology.addAllValues()</title>
      <link>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754841#M58225</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Is there a problem with .addAllValues() or are you looking for a way to add only some values.&amp;nbsp; Because .addAllValues adds ALL values.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You may want to try working with layer files that contain the unique set of values you are interested in.&amp;nbsp;&amp;nbsp; You could add the layer and it would be possible to change the data source on the layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 30 Apr 2012 16:15:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754841#M58225</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2012-04-30T16:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: 10.1: problem with lyr.symbology.addAllValues()</title>
      <link>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754842#M58226</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Yes,&amp;nbsp; i need to&amp;nbsp; adds ALL values and use .addAllValues for it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;But my template layer file contain more values than may contain current feature class connected to this layer file.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;And when i use .addAllValues to limit my layer file to current feature class they broken link between value in layer and value in feature class.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;lyr.lyr have design to [ID]:1,2,3,4,5&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shp.shp in current project have features with [ID]:1,3,5&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;after .addAllValues thay retain design, but it shuffle:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;shp.shp lyr.lyr&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;why reason they doing this? and how to solve this problem?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 01 May 2012 17:33:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754842#M58226</guid>
      <dc:creator>LeonidEliseev</dc:creator>
      <dc:date>2012-05-01T17:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: 10.1: problem with lyr.symbology.addAllValues()</title>
      <link>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754843#M58227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;AddAllValues is reapplying the symbology back to the existing values in a random fashion the same way that the user interface works.&amp;nbsp; For example, add a feature class to the user interface and open the layer properties dialog.&amp;nbsp; Via the symbology tab set the symbology to Unique Value and click the "Add All Values" button mutliple times.&amp;nbsp; Each time you click, the symbols for the existing features change.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I think what you want to do is use arcpy.mapping.Updatelayer.&amp;nbsp; This will update your shapefile using the symbology from the layer file and it will preserve the symbology for the matching symbols.&amp;nbsp; One problem is that UpdateLayer will bring across all unique values into the TOC and if you insert a legend, lables will appear.&amp;nbsp; At 10.1, the way to get around this is to check off "Only show classes that are in the visible extent".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
mxd = arcpy.mapping.MapDocument("current")
df = arcpy.mapping.ListDataFrames(mxd, "layers")[0]
myShape = arcpy.mapping.ListLayers(mxd, "MyShape")[0]
lyrFile = arcpy.mapping.Layer(r"C:\Path\To\layerfile.lyr")
arcpy.UpdateLayer(df, myShape, lyrFile, True)
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I hope this helps,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:01:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/10-1-problem-with-lyr-symbology-addallvalues/m-p/754843#M58227</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-12T08:01:27Z</dc:date>
    </item>
  </channel>
</rss>

