<?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: Adding a shapefile to a blank .mxd in Arcpy in Mapping Questions</title>
    <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616241#M6706</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to run the script outside of ArcMap in command line window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 29 Feb 2016 22:14:17 GMT</pubDate>
    <dc:creator>johnrogers4</dc:creator>
    <dc:date>2016-02-29T22:14:17Z</dc:date>
    <item>
      <title>Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616237#M6702</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can you add several shapefiles to a blank .mxd using a script written with Arcpy? I've started with the code below. The code runs with no errors but the shapefile is not added to the blank .mxd. I'm not sure if you have to first convert the shapefiles to .lyr files? &lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif; font-size: 14px;"&gt;I am trying to run the script outside of ArcMap in command line window.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;CODE style="font-family: Consolas, Menlo, Monaco, 'Lucida Console', 'Liberation Mono', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', 'Courier New', monospace, sans-serif;"&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; arcpy&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;from&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; arcpy &lt;/SPAN&gt;&lt;SPAN class="kwd" style="color: #00008b;"&gt;import&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; env&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="com" style="color: gray;"&gt;# get the map document&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;mxd &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;MapDocument&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="str" style="color: maroon;"&gt;"CURRENT"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="com" style="color: gray;"&gt;# get the data frame&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;df &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;ListDataFrames&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;mxd&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="str" style="color: maroon;"&gt;"*"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;)[&lt;/SPAN&gt;&lt;SPAN class="lit" style="color: maroon;"&gt;0&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;]&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="com" style="color: gray;"&gt;# create a new layer&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;newlayer &lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;=&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;Layer&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;path_to_shapefile_or_feature_class&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN class="com" style="color: gray;"&gt;# add the layer to the map at the bottom of the TOC in data frame 0&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;&lt;BR /&gt;arcpy&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;mapping&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;.&lt;/SPAN&gt;&lt;SPAN class="typ" style="color: #2b91af;"&gt;AddLayer&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;(&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt;df&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="pln" style="color: black;"&gt; newlayer&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;,&lt;/SPAN&gt;&lt;SPAN class="str" style="color: maroon;"&gt;"BOTTOM"&lt;/SPAN&gt;&lt;SPAN class="pun" style="color: black;"&gt;)&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:37:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616237#M6702</guid>
      <dc:creator>johnrogers4</dc:creator>
      <dc:date>2016-02-29T21:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616238#M6703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you are running this code within ArcMap in the Python window, try adding the line:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="_jivemacro_uid_14567820870587371 jive_macro_code jive_text_macro" data-renderedposition="112_8_872_16" jivemacro_uid="_14567820870587371"&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:41:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616238#M6703</guid>
      <dc:creator>JakeSkinner</dc:creator>
      <dc:date>2016-02-29T21:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616239#M6704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you using (r'Path') or just ('Path) for "path_to_shapefile_or_feature_class"? &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:45:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616239#M6704</guid>
      <dc:creator>AravindatStoryMaps</dc:creator>
      <dc:date>2016-02-29T21:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616240#M6705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your code runs fine for me, referencing a shapefile. It adds the layer to the TOC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14567822529212192 jive_text_macro" data-renderedposition="58.906246185302734_7.997159004211426_872_15" jivemacro_uid="_14567822529212192"&gt;&lt;P&gt;newlayer = arcpy.mapping.Layer(r'C:\junk\points.shp')&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Just make sure you're writing a proper Python path (like above).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 21:45:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616240#M6705</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-02-29T21:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616241#M6706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am trying to run the script outside of ArcMap in command line window.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 22:14:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616241#M6706</guid>
      <dc:creator>johnrogers4</dc:creator>
      <dc:date>2016-02-29T22:14:17Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a shapefile to a blank .mxd in Arcpy</title>
      <link>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616242#M6707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;In that case, I'm surprised that it knows what "CURRENT" is (not saying it can't be done, I've just never done it that way). Do you have better luck running &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#/Make_Feature_Layer/00170000006p000000/"&gt;MakeFeatureLayer&lt;/A&gt;​?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 29 Feb 2016 22:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/mapping-questions/adding-a-shapefile-to-a-blank-mxd-in-arcpy/m-p/616242#M6707</guid>
      <dc:creator>DarrenWiens2</dc:creator>
      <dc:date>2016-02-29T22:37:08Z</dc:date>
    </item>
  </channel>
</rss>

