<?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: add  one feature class to  one mxd arcpy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298599#M23120</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you see to be mixing raw and double backslash formatting.&lt;/P&gt;&lt;P&gt;You might want to print the layer name prior to concatenating to see what it is showing&lt;/P&gt;&lt;P&gt;r"C:\Project\Output\\" &amp;nbsp; should be&amp;nbsp;r"C:\Project\Output\"&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 27 Aug 2018 17:45:19 GMT</pubDate>
    <dc:creator>DanPatterson_Retired</dc:creator>
    <dc:date>2018-08-27T17:45:19Z</dc:date>
    <item>
      <title>add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298593#M23114</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm trying to create one mxd for each for layer from an existing MXD.&amp;nbsp; I have list of layers in a mxd but&amp;nbsp; I want&amp;nbsp; one mxd to one layer.&amp;nbsp; This is the script I've been using. It copies all of the layers to the new mxd.&amp;nbsp; &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;... for df in arcpy.mapping.ListLayers(mxd):&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; df.name&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; mxd.saveACopy(r"C:\Project\Output\\" + df.name + ".mxd")&lt;BR /&gt;... del mxd&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 24 Aug 2018 23:12:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298593#M23114</guid>
      <dc:creator>LETITIAKING-BRANCH</dc:creator>
      <dc:date>2018-08-24T23:12:24Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298594#M23115</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;All the layers in the dataframe will be there by default.&amp;nbsp; In order to do what you want to do, you would have to add a layer, save it out, remove the layer, add a new one and repeat.&lt;/P&gt;&lt;P&gt;What is the purpose of having one mxd that only contains 1 layer? Perhaps other solutions can be provided that would meet your goals&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 25 Aug 2018 10:00:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298594#M23115</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-25T10:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298595#M23116</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You would need to create an empty MXD to use as a template for inserting each layer into a new, empty map document:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;import&lt;/SPAN&gt; arcpy

mxd_empty &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;# path to empty mxd&lt;/SPAN&gt;

mxd &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;for&lt;/SPAN&gt; lyr &lt;SPAN class="keyword token"&gt;in&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListLayers&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapDocument&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxd_empty&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dfe &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;ListDataFrames&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mxde&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;mapping&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;AddLayer&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;dfe&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;saveACopy&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;r&lt;SPAN class="string token"&gt;"C:\Project\Output\\"&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;name &lt;SPAN class="operator token"&gt;+&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;".mxd"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;

&lt;SPAN class="keyword token"&gt;del&lt;/SPAN&gt; lyr&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxd&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; dfe&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; mxde&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 14:20:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298595#M23116</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T14:20:14Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298596#M23117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The purpose of having one mxd for one layer is to create a service for each route layer for ArcGIS online.&amp;nbsp; This will used to display each individual bus route.&amp;nbsp; Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 13:48:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298596#M23117</guid>
      <dc:creator>LETITIAKING-BRANCH</dc:creator>
      <dc:date>2018-08-27T13:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298597#M23118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ahhhh… I will share to &lt;A href="https://community.esri.com/space/2106"&gt;ArcGIS Online&lt;/A&gt;‌ … it didn't quite make sense for just working with arcmap or Pro unless you were making personalized lab assignments (each student... different data)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 14:33:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298597#M23118</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-27T14:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298598#M23119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm getting runtime error Invalid mxd filename&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;BR /&gt;... &lt;BR /&gt;... mxd_empty = "c:\project\Output"&lt;BR /&gt;... &lt;BR /&gt;... mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;... for lyr in arcpy.mapping.ListLayers(mxd):&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde = arcpy.mapping.MapDocument(mxd_empty)&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfe = arcpy.mapping.ListDataFrames(mxde)[0]&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(dfe, lyr)&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde.saveACopy(r"C:\Project\Output\\" + lyr.name + ".mxd")&lt;BR /&gt;... &lt;BR /&gt;... del lyr, mxd, dfe, mxde&lt;BR /&gt;... &lt;BR /&gt;Runtime error &lt;BR /&gt;Traceback (most recent call last):&lt;BR /&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 7, in &amp;lt;module&amp;gt;&lt;BR /&gt;&amp;nbsp; File "c:\program files (x86)\arcgis\desktop10.6\arcpy\arcpy\arcobjects\mixins.py", line 651, in __init__&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert (os.path.isfile(mxd) or (mxd.lower() == "current")), gp.getIDMessage(89004, "Invalid MXD filename")&lt;BR /&gt;AssertionError: Invalid MXD filename.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 17:40:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298598#M23119</guid>
      <dc:creator>LETITIAKING-BRANCH</dc:creator>
      <dc:date>2018-08-27T17:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298599#M23120</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you see to be mixing raw and double backslash formatting.&lt;/P&gt;&lt;P&gt;You might want to print the layer name prior to concatenating to see what it is showing&lt;/P&gt;&lt;P&gt;r"C:\Project\Output\\" &amp;nbsp; should be&amp;nbsp;r"C:\Project\Output\"&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 17:45:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298599#M23120</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2018-08-27T17:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298600#M23121</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now I'm getting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;gt;&amp;gt;&amp;gt; import arcpy&lt;BR /&gt;... &lt;BR /&gt;... mxd_empty = "C:\Project\Output"&lt;BR /&gt;... &lt;BR /&gt;... mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;... for lyr in arcpy.mapping.ListLayers(mxd):&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde = arcpy.mapping.MapDocument(mxd_empty)&amp;nbsp;&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfe = arcpy.mapping.ListDataFrames(mxde)[0]&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(dfe, lyr)&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde.saveACopy(r"C:\Project\Output\" + lyr.name + ".mxd")&lt;BR /&gt;... &lt;BR /&gt;... del lyr, mxd, dfe, mxde&lt;BR /&gt;... &lt;BR /&gt;Parsing error SyntaxError: EOL while scanning string literal (line 10)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 18:13:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298600#M23121</guid>
      <dc:creator>LETITIAKING-BRANCH</dc:creator>
      <dc:date>2018-08-27T18:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: add  one feature class to  one mxd arcpy</title>
      <link>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298601#M23122</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp; I had to include the actually empty. mxd in the path not just the directory.&amp;nbsp; Thanks Josh&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;BR /&gt;... &lt;BR /&gt;... mxd_empty = "c:\project\output\empty.mxd"&lt;BR /&gt;... &lt;BR /&gt;... mxd = arcpy.mapping.MapDocument("CURRENT")&lt;BR /&gt;... for lyr in arcpy.mapping.ListLayers(mxd):&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde = arcpy.mapping.MapDocument(mxd_empty)&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dfe = arcpy.mapping.ListDataFrames(mxde)[0]&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(dfe, lyr)&lt;BR /&gt;...&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; mxde.saveACopy(r"C:\Project\Output\\" + lyr.name + ".mxd")&lt;BR /&gt;... &lt;BR /&gt;... del lyr, mxd, dfe, mxde&lt;BR /&gt;...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Aug 2018 19:22:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/add-one-feature-class-to-one-mxd-arcpy/m-p/298601#M23122</guid>
      <dc:creator>LETITIAKING-BRANCH</dc:creator>
      <dc:date>2018-08-27T19:22:31Z</dc:date>
    </item>
  </channel>
</rss>

