<?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: Preconditions for Python scripts to run first in Model builder in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/preconditions-for-python-scripts-to-run-first-in/m-p/538#M88</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been learning how to build models and script tools myself the last few weeks.&amp;nbsp; One thing I read in the ArcGIS Help is that in order to string tools together, including Spatial ETL tools, you need an output to use as a precondition for the next tool.&amp;nbsp; You can't connect tools to tools as preconditions, just variables to tools.&amp;nbsp; One option is to create a Boolean output parameter and set it to True or False depending on whether or not the script is successful.&amp;nbsp; I have been creating a parameter called Successful.&amp;nbsp; You can set it by using the function arcpy.SetParameter at the end of the script.&amp;nbsp; Boolean preconditions will extend the process flow as long as they are True.&amp;nbsp; You can even create two output parameters one for True and one for False.&amp;nbsp; This would allow you to have two separate handles in the model to work from.&amp;nbsp; For example, I made a short script tool to check if a data element exists.&amp;nbsp; The tool is called Exists and produces a True output parameter and a False output parameter, only one being True, each with opposite values.&amp;nbsp; This lets you have two separate workflows if a data element exists or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend getting the book on Model Builder from Esri Press.&amp;nbsp; Model Builder is somewhat tricky.&amp;nbsp; The most important things I have learned the last few weeks are that types are important in Model Builder.&amp;nbsp; Inline variable substitution is very useful, but doesn't work the same with all tools.&amp;nbsp; Always think about what type the tool needs.&amp;nbsp; Some tools seem to be more flexible than others.&amp;nbsp; If all else fails, I have used the Calculate Value tool to process strings and output the exact type I need.&amp;nbsp; Also, intermediate data is really important.&amp;nbsp; Uncheck any outputs that are marked as intermediate data if you want them.&amp;nbsp; I spent three hours the other day trying to figure out why my model runs all the way through and then my file geodatabase disappears.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although it is visual, Model Builder is functional programming and it is easier to organize when I think of it that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nathan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Feb 2012 03:14:10 GMT</pubDate>
    <dc:creator>NathanHeick</dc:creator>
    <dc:date>2012-02-14T03:14:10Z</dc:date>
    <item>
      <title>Preconditions for Python scripts to run first in Model builder</title>
      <link>https://community.esri.com/t5/python-questions/preconditions-for-python-scripts-to-run-first-in/m-p/537#M87</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The preconditions for Python scripts seem to go only way, meaning the script is always forced to be last.&amp;nbsp; Even when I click on the script first and another tool second the precondition is reversed and the script still ends up last.&amp;nbsp; Does anyone know of a way that I could run scripts before other tools in Model Builder?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 01:35:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/preconditions-for-python-scripts-to-run-first-in/m-p/537#M87</guid>
      <dc:creator>MarkBentley</dc:creator>
      <dc:date>2012-02-14T01:35:28Z</dc:date>
    </item>
    <item>
      <title>Re: Preconditions for Python scripts to run first in Model builder</title>
      <link>https://community.esri.com/t5/python-questions/preconditions-for-python-scripts-to-run-first-in/m-p/538#M88</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Mark,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have been learning how to build models and script tools myself the last few weeks.&amp;nbsp; One thing I read in the ArcGIS Help is that in order to string tools together, including Spatial ETL tools, you need an output to use as a precondition for the next tool.&amp;nbsp; You can't connect tools to tools as preconditions, just variables to tools.&amp;nbsp; One option is to create a Boolean output parameter and set it to True or False depending on whether or not the script is successful.&amp;nbsp; I have been creating a parameter called Successful.&amp;nbsp; You can set it by using the function arcpy.SetParameter at the end of the script.&amp;nbsp; Boolean preconditions will extend the process flow as long as they are True.&amp;nbsp; You can even create two output parameters one for True and one for False.&amp;nbsp; This would allow you to have two separate handles in the model to work from.&amp;nbsp; For example, I made a short script tool to check if a data element exists.&amp;nbsp; The tool is called Exists and produces a True output parameter and a False output parameter, only one being True, each with opposite values.&amp;nbsp; This lets you have two separate workflows if a data element exists or not.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I would recommend getting the book on Model Builder from Esri Press.&amp;nbsp; Model Builder is somewhat tricky.&amp;nbsp; The most important things I have learned the last few weeks are that types are important in Model Builder.&amp;nbsp; Inline variable substitution is very useful, but doesn't work the same with all tools.&amp;nbsp; Always think about what type the tool needs.&amp;nbsp; Some tools seem to be more flexible than others.&amp;nbsp; If all else fails, I have used the Calculate Value tool to process strings and output the exact type I need.&amp;nbsp; Also, intermediate data is really important.&amp;nbsp; Uncheck any outputs that are marked as intermediate data if you want them.&amp;nbsp; I spent three hours the other day trying to figure out why my model runs all the way through and then my file geodatabase disappears.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Although it is visual, Model Builder is functional programming and it is easier to organize when I think of it that way.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope that helps.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Nathan&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Feb 2012 03:14:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/preconditions-for-python-scripts-to-run-first-in/m-p/538#M88</guid>
      <dc:creator>NathanHeick</dc:creator>
      <dc:date>2012-02-14T03:14:10Z</dc:date>
    </item>
  </channel>
</rss>

