<?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 Model builder and exception in arcpy script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/model-builder-and-exception-in-arcpy-script/m-p/106126#M8172</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to finish my model... but I have a problem. I need to introduce in my model a script that choise between kriging and IDW/spline interpolation. Kriging is the default method used in my model, but If kriging return an error then I want to run IDW interpolation and pass the result to another tool. &lt;/P&gt;&lt;P&gt;My model &lt;STRONG style="color: #7ed529;"&gt;runs fine with kriging interpolation&lt;/STRONG&gt;, raster was produced and the tool "extract values to points" run successfully. &lt;/P&gt;&lt;P&gt;But if the kriging method return an &lt;STRONG&gt;&lt;SPAN style="color: #e23d39;"&gt;error&lt;/SPAN&gt; &lt;/STRONG&gt;and the script calculate IDW/Spline, raster output was produced but &lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;extract values to point was unable to run successfully.&lt;/STRONG&gt;&lt;/SPAN&gt; And I receive this statement: &lt;SPAN style="color: #eb7a3d;"&gt;"&lt;STRONG&gt;&lt;EM&gt;All the inputs are not current&lt;/EM&gt;&lt;/STRONG&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Immagine.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/171231_Immagine.png" style="width: 620px; height: 249px; display: block; margin-left: auto; margin-right: auto;" /&gt;The error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" height="169" src="https://community.esri.com/legacyfs/online/171236_pastedImage_19.png" style="width: 409px; height: 169.466px; display: block; margin-left: auto; margin-right: auto;" width="409" /&gt;&lt;/P&gt;&lt;P&gt;Parameters settings:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" height="398" src="https://community.esri.com/legacyfs/online/171237_pastedImage_24.png" style="height: 398px; width: 302.241px; display: block; margin-left: auto; margin-right: auto;" width="302" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcpy&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import sys&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from arcpy.sa import *&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;limiti = arcpy.GetParameterAsText(0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.mask = limiti&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.extent = limiti&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;errors = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inFC = arcpy.GetParameterAsText(1)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;campo = arcpy.GetParameterAsText(2)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;outRaster = arcpy.GetParameterAsText(3)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cellSize = 1000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Modello = "Spherical"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;try:&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Kriging_3d(inFC, campo, outRaster, Modello,cellSize, "", "")&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;except Exception:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e = sys.exc_info()[1]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(e.args[0])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(e.args[0])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; errors += 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if errors &amp;gt; 0:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Spline_3d(inFC, campo, outRaster,cellSize, "TENSION", "","")&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Jan 2016 14:07:54 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2016-01-20T14:07:54Z</dc:date>
    <item>
      <title>Model builder and exception in arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-and-exception-in-arcpy-script/m-p/106126#M8172</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm trying to finish my model... but I have a problem. I need to introduce in my model a script that choise between kriging and IDW/spline interpolation. Kriging is the default method used in my model, but If kriging return an error then I want to run IDW interpolation and pass the result to another tool. &lt;/P&gt;&lt;P&gt;My model &lt;STRONG style="color: #7ed529;"&gt;runs fine with kriging interpolation&lt;/STRONG&gt;, raster was produced and the tool "extract values to points" run successfully. &lt;/P&gt;&lt;P&gt;But if the kriging method return an &lt;STRONG&gt;&lt;SPAN style="color: #e23d39;"&gt;error&lt;/SPAN&gt; &lt;/STRONG&gt;and the script calculate IDW/Spline, raster output was produced but &lt;SPAN style="color: #e23d39;"&gt;&lt;STRONG&gt;extract values to point was unable to run successfully.&lt;/STRONG&gt;&lt;/SPAN&gt; And I receive this statement: &lt;SPAN style="color: #eb7a3d;"&gt;"&lt;STRONG&gt;&lt;EM&gt;All the inputs are not current&lt;/EM&gt;&lt;/STRONG&gt;"&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Immagine.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/171231_Immagine.png" style="width: 620px; height: 249px; display: block; margin-left: auto; margin-right: auto;" /&gt;The error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-2 jive-image" height="169" src="https://community.esri.com/legacyfs/online/171236_pastedImage_19.png" style="width: 409px; height: 169.466px; display: block; margin-left: auto; margin-right: auto;" width="409" /&gt;&lt;/P&gt;&lt;P&gt;Parameters settings:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-3 jive-image" height="398" src="https://community.esri.com/legacyfs/online/171237_pastedImage_24.png" style="height: 398px; width: 302.241px; display: block; margin-left: auto; margin-right: auto;" width="302" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import arcpy&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;import sys&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;from arcpy.sa import *&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;limiti = arcpy.GetParameterAsText(0)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.mask = limiti&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;arcpy.env.extent = limiti&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;errors = 0&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;inFC = arcpy.GetParameterAsText(1)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;campo = arcpy.GetParameterAsText(2)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;outRaster = arcpy.GetParameterAsText(3)&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;cellSize = 1000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Modello = "Spherical"&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;try:&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Kriging_3d(inFC, campo, outRaster, Modello,cellSize, "", "")&amp;nbsp; &lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;except Exception:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e = sys.exc_info()[1]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; print(e.args[0])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(e.args[0])&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; errors += 1&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;if errors &amp;gt; 0:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Spline_3d(inFC, campo, outRaster,cellSize, "TENSION", "","")&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Jan 2016 14:07:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-and-exception-in-arcpy-script/m-p/106126#M8172</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2016-01-20T14:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Model builder and exception in arcpy script</title>
      <link>https://community.esri.com/t5/python-questions/model-builder-and-exception-in-arcpy-script/m-p/106127#M8173</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are going to want a 'finally' block after your 'except' block to capture the errors:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: bold; font-style: inherit; font-family: inherit;"&gt;finally:&lt;/SPAN&gt;
&lt;SPAN style="font-weight: bold; font-style: inherit; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if errors &amp;gt; 0:&lt;/SPAN&gt;
&lt;SPAN style="font-weight: bold; font-style: inherit; font-family: inherit;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Spline_3d(inFC, campo, outRaster,cellSize, "TENSION", "","")&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 06:27:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/model-builder-and-exception-in-arcpy-script/m-p/106127#M8173</guid>
      <dc:creator>LukeSturtevant</dc:creator>
      <dc:date>2021-12-11T06:27:31Z</dc:date>
    </item>
  </channel>
</rss>

