<?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 layer (existing point shapefile) from tool output in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/adding-a-layer-existing-point-shapefile-from-tool/m-p/64017#M5228</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3200"&gt;Jeff Barrette&lt;/A&gt;‌ made the following suggestion through another &lt;A _jive_internal="true" href="https://community.esri.com/thread/72195"&gt;post&lt;/A&gt;‌ and the tool is now working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace: &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;precipLayer = arcpy.MakeFeatureLayer_management(r"D:\Active\ArcPY\10x\ScrumWorks\Data\Drive_A\basin_utmcopy.shp")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;With:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;precipLayer =arcpy.mapping.Layer(r"D:\Active\ArcPY\10x\ScrumWorks\Data\Drive_A\basin_utmcopy.shp")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;And remove getOutput(0):&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;#arcpy.mapping.AddLayer(df, precipLayer.getOutput(0), "TOP")&amp;nbsp;&amp;nbsp; # GOT ERROR: getOutput(0) doesn't exist&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.mapping.AddLayer(df, precipLayer, "TOP")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 01 Dec 2014 19:39:45 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2014-12-01T19:39:45Z</dc:date>
    <item>
      <title>Adding a layer (existing point shapefile) from tool output</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-layer-existing-point-shapefile-from-tool/m-p/64016#M5227</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;My question: can someone please suggest a fix to the code below OR suggest a better way to add an existing point shapefile to a map (not to a geodatabase as this tool will be accessed from a web map using ArcGIS API for JS through REST services once it is published to a server)?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can't seem to add a point shapefile layer to a map from within a tool, though it works fine from the command line. I've read &lt;A _jive_internal="true" data-containerid="2145" data-containertype="14" data-objectid="72195" data-objecttype="1" href="https://community.esri.com/thread/72195"&gt;this &lt;/A&gt;thread and followed its suggestions, but still nothing... The particular line that is failing is the last one from below:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;precipLayer = arcpy.MakeFeatureLayer_management(precipShape,precipShape) # NOTE: precipShape = existing point shapefile&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P&gt;arcpy.mapping.AddLayer(df, precipLayer.getOutput(0), "TOP")&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error from running the tool is:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "C:\Users\...\getData.py", line 83, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.mapping.AddLayer(df, precipLayer.getOutput(0), "TOP")&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.2\arcpy\arcpy\utils.py", line 181, in fn_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.2\arcpy\arcpy\mapping.py", line 49, in AddLayer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert isinstance(add_layer, Layer)&lt;/P&gt;&lt;P&gt;AssertionError&lt;/P&gt;&lt;P&gt;Failed to execute (getData).&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I run this from the command line, then it works (adds the layer twice, of course: once from MadeFeatureLayer and once from AddLayer). But if I remove the .getOutput(0) and run it in at the command line, then I basically get the same error as running it as a tool:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Runtime error &lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "&amp;lt;string&amp;gt;", line 1, in &amp;lt;module&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.2\arcpy\arcpy\utils.py", line 181, in fn_&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return fn(*args, **kw)&lt;/P&gt;&lt;P&gt;&amp;nbsp; File "c:\program files\arcgis\desktop10.2\arcpy\arcpy\mapping.py", line 49, in AddLayer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; assert isinstance(add_layer, Layer)&lt;/P&gt;&lt;P&gt;AssertionError&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 28 Nov 2014 18:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-layer-existing-point-shapefile-from-tool/m-p/64016#M5227</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2014-11-28T18:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a layer (existing point shapefile) from tool output</title>
      <link>https://community.esri.com/t5/python-questions/adding-a-layer-existing-point-shapefile-from-tool/m-p/64017#M5228</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migrated-users/3200"&gt;Jeff Barrette&lt;/A&gt;‌ made the following suggestion through another &lt;A _jive_internal="true" href="https://community.esri.com/thread/72195"&gt;post&lt;/A&gt;‌ and the tool is now working:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Replace: &lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;precipLayer = arcpy.MakeFeatureLayer_management(r"D:\Active\ArcPY\10x\ScrumWorks\Data\Drive_A\basin_utmcopy.shp")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;With:&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;precipLayer =arcpy.mapping.Layer(r"D:\Active\ArcPY\10x\ScrumWorks\Data\Drive_A\basin_utmcopy.shp")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;And remove getOutput(0):&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;df = arcpy.mapping.ListDataFrames(mxd)[0]&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;#arcpy.mapping.AddLayer(df, precipLayer.getOutput(0), "TOP")&amp;nbsp;&amp;nbsp; # GOT ERROR: getOutput(0) doesn't exist&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;arcpy.mapping.AddLayer(df, precipLayer, "TOP")&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 19:39:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/adding-a-layer-existing-point-shapefile-from-tool/m-p/64017#M5228</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2014-12-01T19:39:45Z</dc:date>
    </item>
  </channel>
</rss>

