<?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: Script Tool Errors on a For loop with an If Else Statement, also For loop will not run with GetParameterAsText()? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578492#M45327</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This cleared up my invalid syntax but I am continuing to get this traceback&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Python27\ArcGIS10.7\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;BR /&gt; exec codeObject in __main__.__dict__&lt;BR /&gt; File "C:\GIS\Python\CROSSING_TABLES\CROSSING_TABLES.PY", line 8, in &amp;lt;module&amp;gt;&lt;BR /&gt; for fc in features:&lt;BR /&gt;TypeError: 'NoneType' object is not iterable&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 25 Feb 2020 13:34:06 GMT</pubDate>
    <dc:creator>CarolineBanville</dc:creator>
    <dc:date>2020-02-25T13:34:06Z</dc:date>
    <item>
      <title>Script Tool Errors on a For loop with an If Else Statement, also For loop will not run with GetParameterAsText()?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578490#M45325</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm writing a script tool to run multiple processes.&amp;nbsp; See below:&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/483137_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;P&gt;Two problems.&amp;nbsp; I was able to get the for loop to run before adding the if else statement.&amp;nbsp; I need the loop to do extra steps if it is a polyline feature where as if it is a point or polygon it only needs to do the one process (Locate Features).&amp;nbsp; Right now when I run it I just get invalid syntax.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Second, I am able to get this script to work if my arcpy.env.workspace = "C:\ExamplePath\" but when trying to use the Get Parameter As Text the for loop will not run.&amp;nbsp; It thinks there is no data where I tell it there is.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help will be greatly appreciated!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 24 Feb 2020 20:39:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578490#M45325</guid>
      <dc:creator>CarolineBanville</dc:creator>
      <dc:date>2020-02-24T20:39:05Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Errors on a For loop with an If Else Statement, also For loop will not run with GetParameterAsText()?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578491#M45326</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Two easy changes to get your IF block to work:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; You only need to do the Describe once; it returns a Describe object from which you can get the basename and feature type, rather than repeatedly returning to the feature class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Use the ShapeType property of the Descibe object to determine if it's a polyline feature class.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your IF block would start like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&amp;nbsp;&amp;nbsp; for fc in features:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Desc = arcpy.Describe(fc)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if Desc.shapeType == "Polyline":
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;outFC = Desc.baseName + "INT.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;outFC2 = Desc.baseName + "INT_sp.shp"
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;# and so on....


&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 16:38:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578491#M45326</guid>
      <dc:creator>EarlSarow</dc:creator>
      <dc:date>2021-12-12T16:38:52Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Errors on a For loop with an If Else Statement, also For loop will not run with GetParameterAsText()?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578492#M45327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This cleared up my invalid syntax but I am continuing to get this traceback&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt; File "C:\Python27\ArcGIS10.7\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py", line 325, in RunScript&lt;BR /&gt; exec codeObject in __main__.__dict__&lt;BR /&gt; File "C:\GIS\Python\CROSSING_TABLES\CROSSING_TABLES.PY", line 8, in &amp;lt;module&amp;gt;&lt;BR /&gt; for fc in features:&lt;BR /&gt;TypeError: 'NoneType' object is not iterable&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 13:34:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578492#M45327</guid>
      <dc:creator>CarolineBanville</dc:creator>
      <dc:date>2020-02-25T13:34:06Z</dc:date>
    </item>
    <item>
      <title>Re: Script Tool Errors on a For loop with an If Else Statement, also For loop will not run with GetParameterAsText()?</title>
      <link>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578493#M45328</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Actually I just ran it through the script tool and it worked perfectly!&amp;nbsp; Thanks so much for your help!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 25 Feb 2020 13:44:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/script-tool-errors-on-a-for-loop-with-an-if-else/m-p/578493#M45328</guid>
      <dc:creator>CarolineBanville</dc:creator>
      <dc:date>2020-02-25T13:44:49Z</dc:date>
    </item>
  </channel>
</rss>

