<?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: How? bring custom python-script tool's output back to modelBuilder ArcGIS Pro in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681246#M30119</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, of course!&amp;nbsp; I already get the input with GetParameterAsText(#) functions!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just&amp;nbsp;add this line:&amp;nbsp;&lt;EM&gt;arcpy.SetParameter(2, outFeatures).&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Apr 2020 09:11:52 GMT</pubDate>
    <dc:creator>LessieOC</dc:creator>
    <dc:date>2020-04-28T09:11:52Z</dc:date>
    <item>
      <title>How? bring custom python-script tool's output back to modelBuilder ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681244#M30117</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I created a python script tool.&amp;nbsp;The user runs the script after setting&amp;nbsp;the inputs. I would like to bring the generated ouput in the code variable&amp;nbsp;&lt;STRONG&gt;outFeatures&lt;/STRONG&gt;&amp;nbsp;(polygons) back into the model&amp;nbsp;as the script's output.&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; . . .&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;outFeatures&lt;/STRONG&gt; = os.path.join(shp_output_folder,"&lt;STRONG&gt;cont_hs.shp&lt;/STRONG&gt;")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;. . .&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="490076" alt="" class="jive-emoji image-1 jive-image" height="408" src="https://community.esri.com/legacyfs/online/490076_pyScript_Mbuildr_q.jpg" width="605" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get&amp;nbsp;a blank output in the model as shown in pic, no matter what.&amp;nbsp;Nothing I tried works:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(1) setting the script's &lt;STRONG&gt;outFeatures&lt;/STRONG&gt; output parameter&amp;nbsp;&lt;EM&gt;Data Type&lt;/EM&gt; as "Shapefile" or "feature class" or "file"&amp;nbsp;or "string" and as a "Derived"&amp;nbsp;&lt;EM&gt;Type,&amp;nbsp;&lt;/EM&gt;yield a blank output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(2) Within the python code, I tried adding the result object and using the &lt;EM&gt;result[0]&lt;/EM&gt; object as an alternate &lt;STRONG&gt;output&lt;/STRONG&gt;&amp;nbsp;variable even though the string is the same as in&amp;nbsp;outFeatures&lt;STRONG&gt;, &lt;/STRONG&gt;anyway&lt;STRONG&gt;.&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;. . .&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;result = arcpy.DeleteField_management (&amp;nbsp;&lt;STRONG&gt;outFeatures&lt;/STRONG&gt;,["ht_v_OBJEC", "ht_v_index"] )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;output = result[0]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;...using ArcGIS Pro 2.5, Any advise &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2020 12:45:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681244#M30117</guid>
      <dc:creator>LessieOC</dc:creator>
      <dc:date>2020-04-27T12:45:16Z</dc:date>
    </item>
    <item>
      <title>Re: How? bring custom python-script tool's output back to modelBuilder ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681245#M30118</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It is not enough to create an output parameter in the ModelBuilder interface for your script. This just tells ModelBuilder the script should generate output, and how many parameters and what type, but you still need to explicitly set that output using &lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;arcpy.SetParameter()&lt;/STRONG&gt;&lt;/SPAN&gt; or &lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;arcpy.SetParameterAsText()&lt;/STRONG&gt;&lt;/SPAN&gt;, see the example below. Note that script parameters are called by index number, starting at 0 and upwards. So in your case, I see "outFeatures" as the third parameter, which has index number 2. So you need to set index number 2.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;By the way, the script below can both act as a ModelBuilder tool, and be called as function of an imported Python module, by importing the script in another script module, and then calling &lt;STRONG&gt;&lt;SPAN style="font-size: 13px;"&gt;&amp;lt;YOUR_SCRIPT_NAME&amp;gt;&lt;/SPAN&gt;.main()&lt;/STRONG&gt;&lt;SPAN style="font-size: 15px;"&gt;.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;import arcpy &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;def main(inputVariable):&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; # Do something &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; return &amp;lt;YOUR_SCRIPT_RESULT&amp;gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;if __name__ == '__main__':&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; # Get *input* for script&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; inputVariable = arcpy.GetParameter(0)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; # Call main function&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; returnValue = main(inputVariable)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; # Set *output* for script, NOTICE the parameter index number of the parameter before the variable to return.&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp; arcpy.SetParameter(1,returnValue)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Apr 2020 13:10:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681245#M30118</guid>
      <dc:creator>MarcoBoeringa</dc:creator>
      <dc:date>2020-04-27T13:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: How? bring custom python-script tool's output back to modelBuilder ArcGIS Pro</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681246#M30119</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh, of course!&amp;nbsp; I already get the input with GetParameterAsText(#) functions!&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just&amp;nbsp;add this line:&amp;nbsp;&lt;EM&gt;arcpy.SetParameter(2, outFeatures).&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Apr 2020 09:11:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/how-bring-custom-python-script-tool-s-output-back/m-p/681246#M30119</guid>
      <dc:creator>LessieOC</dc:creator>
      <dc:date>2020-04-28T09:11:52Z</dc:date>
    </item>
  </channel>
</rss>

