<?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: Wanting to add layer to Table of Contents via Python in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570837#M44762</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That worked great, thank you!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Mar 2011 14:20:48 GMT</pubDate>
    <dc:creator>StevenMenefee</dc:creator>
    <dc:date>2011-03-30T14:20:48Z</dc:date>
    <item>
      <title>Wanting to add layer to Table of Contents via Python</title>
      <link>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570836#M44761</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to do something that I thought would be simple!&amp;nbsp; We use a number of shapefiles frequently and I'd like to create buttons within ArcMap that you click that will add a particular shapefile to the Table of Contents.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I decided I would write the code in Python, add that as a Script in Arctoolbox and somehow make a button that will look at that Script.&amp;nbsp; Anyway, the code I'm using SEEMS to be working.&amp;nbsp; However, I can't seem to see the layer within the Table of Contents.&amp;nbsp; Below is the code I'm using that I am adding a Script to (no Parameters).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;import arcpy&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;mxd = arcpy.mapping.MapDocument("C:\\Gis\\Python\\mxd\\test2.mxd")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;addLayer = arcpy.mapping.Layer("C:\\Gis\\GisMaps\\Attica\\layer.lyr")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.mapping.AddLayer(df, addLayer)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshActiveView()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.RefreshTOC()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del mxd, addLayer&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Any help would be much appreciated, thanks!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Mar 2011 12:42:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570836#M44761</guid>
      <dc:creator>StevenMenefee</dc:creator>
      <dc:date>2011-03-29T12:42:57Z</dc:date>
    </item>
    <item>
      <title>Re: Wanting to add layer to Table of Contents via Python</title>
      <link>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570837#M44762</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That worked great, thank you!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Mar 2011 14:20:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570837#M44762</guid>
      <dc:creator>StevenMenefee</dc:creator>
      <dc:date>2011-03-30T14:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Wanting to add layer to Table of Contents via Python</title>
      <link>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570838#M44763</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding RefreshActiveView and RefreshTOC get the the layer to stay in the mxd&amp;nbsp;before saving. Weird this is not in the documentation for AddLayer.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Dec 2017 19:01:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/wanting-to-add-layer-to-table-of-contents-via/m-p/570838#M44763</guid>
      <dc:creator>ArjunDongre</dc:creator>
      <dc:date>2017-12-14T19:01:18Z</dc:date>
    </item>
  </channel>
</rss>

