<?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: Error with arcpy.mapping.ListLayers - Please Help in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233385#M18105</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The symbology object only supports a limited number of renderers (e.g., Unique Value, Graduated Color, Graduated Symbol, and Raster Classified).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are trying to .AddAllValues to a single symbol renderer.&amp;nbsp; You can't do that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The help topic from &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UniqueValuesSymbology/00s30000005s000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UniqueValuesSymbology/00s30000005s000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;shows a code sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "Population")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
&amp;nbsp; lyr.symbology.valueField = "SUB_REGION"
&amp;nbsp; lyr.symbology.addAllValues()
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sat, 11 Dec 2021 11:48:31 GMT</pubDate>
    <dc:creator>JeffBarrette</dc:creator>
    <dc:date>2021-12-11T11:48:31Z</dc:date>
    <item>
      <title>Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233378#M18098</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello, everyone. I have a layer file that points at a FeatureClass. This FeatureClass periodically receives new data. I need to update the layer file so that it recognizes the new data. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm trying to use the code found at: &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UpdateLayer/00s30000003p000000/&lt;/A&gt;&lt;SPAN&gt; as a starting point but it's erroring out saying "&lt;/SPAN&gt;&lt;STRONG&gt;AttributeError: 'Layer' object has no attribute 'symbology'&lt;/STRONG&gt;&lt;SPAN&gt;"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Ive been grinding on this for a week now and I'm totally stumped here. The layer file does have symbology set up (see attached screenshot), so I've no idea what the problem is. I'm in desperate need of help and would appreciate any suggestions. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My code is as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
from arcpy import env

env.workspace = os.getcwd()


mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd")

# Dataframe stuff - perform an arcpy.mapping UpdateLayer (using the above pre-authors layer file)
df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0]
sourceLayer = arcpy.mapping.Layer(env.workspace + r"\USWC_1km_WGS_1984.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)

# Refresh the layers unique value symbology so that it is referencing the current data

lyr = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] # HERE'S WHERE THE ERROR HAPPENS #######

lyr.symbology.addAllValues()

arcpy.RefreshActiveView()
arcpy.RefreshTOC()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233378#M18098</guid>
      <dc:creator>MatthewGerbrandt</dc:creator>
      <dc:date>2021-12-11T11:48:23Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233379#M18099</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;try changing to this &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;sourceLayer = arcpy.mapping.Layer(env.workspace + "/USWC_1km_WGS_1984.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tested your code and it works fine. Also I always try to use / instead of \ in path names&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 14:16:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233379#M18099</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2012-12-27T14:16:40Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233380#M18100</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matthew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can simplify your code if you're updating a layer file in your MXD.&amp;nbsp; Try the following using the Python window within ArcMap:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env
env.workspace = os.getcwd()

mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
lyr = arcpy.mapping.Layer("RecentData")

lyr.symbology.addAllValues()

arcpy.RefreshActiveView()
arcpy.RefreshTOC()&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233380#M18100</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2021-12-11T11:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233381#M18101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you for taking a look at my code. Unfortunately, I could not solve the problem with the code you provided. The code and error are as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy, os
from arcpy import env

env.workspace = os.getcwd()


mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd")

# Dataframe stuff - perform an arcpy.mapping UpdateLayer (using the above pre-authors layer file)
df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0]
updateLayer = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0]
sourceLayer = arcpy.mapping.Layer(env.workspace + "/USWC_1km_WGS_1984.lyr")
arcpy.mapping.UpdateLayer(df, updateLayer, sourceLayer, True)

# Refresh the layers unique value symbology so that it is referencing the current data

# HERE'S WHERE THE ERROR HAPPENS #######
sourceLayer.symbology.addAllValues()
# AttributeError: 'Layer' object has no attribute 'symbology'

arcpy.RefreshActiveView()
arcpy.RefreshTOC()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:13:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233381#M18101</guid>
      <dc:creator>MatthewGerbrandt</dc:creator>
      <dc:date>2021-12-12T16:13:05Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233382#M18102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Wouldn't this be simpler. I just ran this and it again ran fine with the expected results&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy

mxd = arcpy.mapping.MapDocument("CURRENT")

df = arcpy.mapping.ListDataFrames(mxd, "DataFrame")[0]

# Refresh the layers unique value symbology so that it is referencing the current data
lyr = arcpy.mapping.ListLayers(mxd, "TestingLayer", df)[0] 

lyr.symbology.addAllValues()

arcpy.RefreshActiveView()
arcpy.RefreshTOC()
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233382#M18102</guid>
      <dc:creator>CarlSunderman</dc:creator>
      <dc:date>2021-12-11T11:48:28Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233383#M18103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hmmm... It looks like you're running code from within ArcGIS Desktop and I'm trying to run this as a stand-alone script. Perhaps that's the difference. I need this to run as a stand-alone automated script. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried using a variation of your code (as follows) but the error remains. I've also attached a screenshot of the MXD in case that adds any clarity. I really appreciate your help.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy, os
from arcpy import env

env.workspace = os.getcwd()

mxd = arcpy.mapping.MapDocument(env.workspace + r"\CoastalCurrentsData.mxd")

df = arcpy.mapping.ListDataFrames(mxd, "CoastalCurrentsData")[0]

# Refresh the layers unique value symbology so that it is referencing the current data
lyr = arcpy.mapping.ListLayers(mxd, "RecentData", df)[0] 

lyr.symbology.addAllValues()
# AttributeError: 'Layer' object has no attribute 'symbology'

arcpy.RefreshActiveView()
arcpy.RefreshTOC()

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:13:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233383#M18103</guid>
      <dc:creator>MatthewGerbrandt</dc:creator>
      <dc:date>2021-12-12T16:13:07Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233384#M18104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Matthew,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you created the layer file with Single Symbol symbology, new features should automatically display once the feature class is updated.&amp;nbsp; You would only need to apply the code if you used Unique Values for the symbology.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can test this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&amp;nbsp; Add a feature class to ArcMap (symbology will default to Single Symbol)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;2.&amp;nbsp; Create a layer file&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;3.&amp;nbsp; Remove the feature class and add the layer file to the MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;4.&amp;nbsp; Save the MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;5.&amp;nbsp; Start a new map document and add the feature class&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;6.&amp;nbsp; Start an edit session, add a new feature, save edits&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;7.&amp;nbsp; Open the previously saved MXD&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The new feature should appear.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 27 Dec 2012 17:06:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233384#M18104</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2012-12-27T17:06:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233385#M18105</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The symbology object only supports a limited number of renderers (e.g., Unique Value, Graduated Color, Graduated Symbol, and Raster Classified).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You are trying to .AddAllValues to a single symbol renderer.&amp;nbsp; You can't do that.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The help topic from &lt;/SPAN&gt;&lt;A href="http://resources.arcgis.com/en/help/main/10.1/#/UniqueValuesSymbology/00s30000005s000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;http://resources.arcgis.com/en/help/main/10.1/#/UniqueValuesSymbology/00s30000005s000000/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;shows a code sample:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;
import arcpy
mxd = arcpy.mapping.MapDocument("current")
lyr = arcpy.mapping.ListLayers(mxd, "Population")[0]
if lyr.symbologyType == "UNIQUE_VALUES":
&amp;nbsp; lyr.symbology.valueField = "SUB_REGION"
&amp;nbsp; lyr.symbology.addAllValues()
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
del mxd
&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Jeff&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:48:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233385#M18105</guid>
      <dc:creator>JeffBarrette</dc:creator>
      <dc:date>2021-12-11T11:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Error with arcpy.mapping.ListLayers - Please Help</title>
      <link>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233386#M18106</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Matthew,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Did you ever figure out why you were getting the error: &lt;STRONG style="font-size: 12px; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;'Layer' object has no attribute 'symbology'&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm running into the same problem. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for any help,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Brian &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 26 Aug 2014 14:57:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-with-arcpy-mapping-listlayers-please-help/m-p/233386#M18106</guid>
      <dc:creator>BrianHebert</dc:creator>
      <dc:date>2014-08-26T14:57:08Z</dc:date>
    </item>
  </channel>
</rss>

