<?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 If empty output then.... in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/if-empty-output-then/m-p/223661#M7714</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to implement an if statement that will allow a model to take one of two directions if the output of a tool is empty (e.g. a feature is selected by it's location within a buffer. there may not be any features inside of that buffer). this is where i need to have the model go to a different tool. I do not know any python, so I wondered if anyone could give me an example, or something to start with?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gratefully,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Aaron&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Sep 2010 12:53:41 GMT</pubDate>
    <dc:creator>AaronBarkhurst</dc:creator>
    <dc:date>2010-09-09T12:53:41Z</dc:date>
    <item>
      <title>If empty output then....</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/if-empty-output-then/m-p/223661#M7714</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to implement an if statement that will allow a model to take one of two directions if the output of a tool is empty (e.g. a feature is selected by it's location within a buffer. there may not be any features inside of that buffer). this is where i need to have the model go to a different tool. I do not know any python, so I wondered if anyone could give me an example, or something to start with?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Gratefully,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Aaron&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Sep 2010 12:53:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/if-empty-output-then/m-p/223661#M7714</guid>
      <dc:creator>AaronBarkhurst</dc:creator>
      <dc:date>2010-09-09T12:53:41Z</dc:date>
    </item>
    <item>
      <title>Re: If empty output then....</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/if-empty-output-then/m-p/223662#M7715</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Aaron,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Here would be your high-level workflow:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;1. Write the script to contain the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Using_If_Then_Else_logic_for_branching/002w00000022000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;if-then-else logic&lt;/A&gt;&lt;SPAN&gt;. Below is a sample python code based on your example of determining if the feature is empty or not:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;import arcpy

inputFC = arcpy.GetParameterAsText(0) #Input for the script tool

#Evaluate if input has greater than 0 features
if (arcpy.GetCount_management(inputFC) &amp;gt; 0):
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(1, "true") #Output Boolean parameter for feature count greater than 0, set to true
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(2, "false")#Output Boolean parameter for feature count equal to 0, set to false
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Feature count greater than 0") 

#If it does not have greater than 0 features it will have 0
else:
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(1, "false")#Output Boolean parameter for feature count greater than 0, set to false
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(2, "true")#Output Boolean parameter for feature count equal to 0, set to true
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Feature count equal to 0") &lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. In ArcMap or Catalog create a new Toolbox and add a New Script Tool. See the &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Adding_a_script_tool/00150000001r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;Adding a script tool&lt;/A&gt;&lt;SPAN&gt; topic for more information.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;3. The Script Tool will have 3 parameters. First will be the input feature class or feature layer, second and third will be for the boolean outputs we created in the python script. &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/Understanding_script_tool_parameters/001500000007000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;Understanding script tool parameters&lt;/A&gt;&lt;SPAN&gt; is a good help topic on this process.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;4. Add the Script to your model and &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#/A_quick_tour_of_using_preconditions/002w0000007r000000/" rel="nofollow noopener noreferrer" target="_blank"&gt;set up the preconditions&lt;/A&gt;&lt;SPAN&gt; based on the boolean output parameters of your script tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;-Chris&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 10:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/if-empty-output-then/m-p/223662#M7715</guid>
      <dc:creator>ChrisFox3</dc:creator>
      <dc:date>2021-12-11T10:53:40Z</dc:date>
    </item>
  </channel>
</rss>

