<?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 legend.updateItem Brings IndexError: 0 in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/legend-updateitem-brings-indexerror-0/m-p/488315#M38136</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on a script to automate FEMA maps. My legend element is empty, and I need to add a shapefile (with set symbology), named S_FLD_HAZ_AR into the Legend. Here is what I have for my script so far, specifically to add the layer into the map legend. When I try to add the layer into the legend, it gives the indexerror: 0. Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("Current")&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;lyrFile = arcpy.mapping.Layer(r"S:\XXXXX\GEO_DATA\Federal\FEMA\Berkeley_FEMA\FIRM\45015C_20181210_SPintl\S_FLD_HAZ_AR.shp")&lt;BR /&gt;arcpy.mapping.AddLayer(df, lyrFile, "TOP")&lt;BR /&gt;styleItem = arcpy.mapping.ListStyleItems("ESRI.style", "Legend Items")[2]&lt;BR /&gt;legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]&lt;BR /&gt;lyr = arcpy.mapping.ListLayers(mxd, 'S_FLD_HAZ_AR', df)[0]&amp;nbsp;&lt;BR /&gt;legend.updateItem(lyr, styleItem)&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Jul 2019 14:33:11 GMT</pubDate>
    <dc:creator>NathanRyan1</dc:creator>
    <dc:date>2019-07-02T14:33:11Z</dc:date>
    <item>
      <title>legend.updateItem Brings IndexError: 0</title>
      <link>https://community.esri.com/t5/python-questions/legend-updateitem-brings-indexerror-0/m-p/488315#M38136</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm working on a script to automate FEMA maps. My legend element is empty, and I need to add a shapefile (with set symbology), named S_FLD_HAZ_AR into the Legend. Here is what I have for my script so far, specifically to add the layer into the map legend. When I try to add the layer into the legend, it gives the indexerror: 0. Any help would be greatly appreciated!&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;mxd = arcpy.mapping.MapDocument("Current")&lt;BR /&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;BR /&gt;lyrFile = arcpy.mapping.Layer(r"S:\XXXXX\GEO_DATA\Federal\FEMA\Berkeley_FEMA\FIRM\45015C_20181210_SPintl\S_FLD_HAZ_AR.shp")&lt;BR /&gt;arcpy.mapping.AddLayer(df, lyrFile, "TOP")&lt;BR /&gt;styleItem = arcpy.mapping.ListStyleItems("ESRI.style", "Legend Items")[2]&lt;BR /&gt;legend = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT")[0]&lt;BR /&gt;lyr = arcpy.mapping.ListLayers(mxd, 'S_FLD_HAZ_AR', df)[0]&amp;nbsp;&lt;BR /&gt;legend.updateItem(lyr, styleItem)&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Jul 2019 14:33:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/legend-updateitem-brings-indexerror-0/m-p/488315#M38136</guid>
      <dc:creator>NathanRyan1</dc:creator>
      <dc:date>2019-07-02T14:33:11Z</dc:date>
    </item>
  </channel>
</rss>

