<?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: Help! ArcPy tool with if else statement not fully working in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275208#M21255</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/496264_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 11 Jun 2020 23:25:30 GMT</pubDate>
    <dc:creator>ChristopherSanchez</dc:creator>
    <dc:date>2020-06-11T23:25:30Z</dc:date>
    <item>
      <title>Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275205#M21252</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi everyone. I am creating am making a script with arcpro and need some help. The tool will delete a shapefile in my gdb if it matches the name of my input, but if it doesn't find a shapefile in the gdb it will create a shapefile with that name. the tool will online get to the point of using the delete tool, but doesnt show that it is using the create feature class tool. any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def CheckFcExists(ws,inFC, outFC):&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.env.workspace = ws&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if inFC == inFC:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.Delete_management(inFC)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.AddMessage(f"deleting...")&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;else: &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.CreateFeatureclass_management(inFC,outFC)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.AddMessage(f"creating...")&lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt; &lt;BR /&gt;workspace = arcpy.GetParameterAsText(0)&lt;BR /&gt;inFeatureClass = arcpy.GetParameterAsText(1)&lt;BR /&gt;outFeatureClass = arcpy.GetParameterAsText(2)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if __name__ == "__main__":&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;workspace = r"C:\Users\tophe\Documents\ArcGIS\Projects\Lab3_Programming\Lab3.gdb"&lt;BR /&gt; &lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;CheckFcExists(workspace, inFeatureClass, outFeatureClass)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2020 22:06:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275205#M21252</guid>
      <dc:creator>ChristopherSanchez</dc:creator>
      <dc:date>2020-06-11T22:06:29Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275206#M21253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you have a redundant definition in your inFC == inFC line, so it doesn't matter what you pass the function, it will always be true.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;a &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"real a"&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;def&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;test&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; a &lt;SPAN class="operator token"&gt;==&lt;/SPAN&gt; a&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;a&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;
        &lt;SPAN class="keyword token"&gt;print&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"nope"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
        

test&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"not a"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;not&lt;/SPAN&gt; a&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:25:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275206#M21253</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2021-12-11T13:25:02Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275207#M21254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I changed it from inFC==inFC to ws == inFC, but it gives me back an error when I run the tool. i also put the input feature class name without the .shp.&lt;/P&gt;&lt;P&gt;Thank you for your help&lt;/P&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/496263_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2020 23:24:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275207#M21254</guid>
      <dc:creator>ChristopherSanchez</dc:creator>
      <dc:date>2020-06-11T23:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275208#M21255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/496264_pastedImage_1.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 11 Jun 2020 23:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275208#M21255</guid>
      <dc:creator>ChristopherSanchez</dc:creator>
      <dc:date>2020-06-11T23:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275209#M21256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Not exactly sure what you are trying to do, but a shapefile normally reside in a folder but you are checking it against a gdb.&amp;nbsp; Are you trying to see if a featureclass exists with the name of the shapefile (ie minus the .shp extension),&amp;nbsp;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2020 00:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275209#M21256</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2020-06-12T00:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275210#M21257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yeah I'm trying to see if it exists in the gdb, if it does im deleting it, if what I input doesn't exist i'm creating it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 12 Jun 2020 00:04:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275210#M21257</guid>
      <dc:creator>ChristopherSanchez</dc:creator>
      <dc:date>2020-06-12T00:04:35Z</dc:date>
    </item>
    <item>
      <title>Re: Help! ArcPy tool with if else statement not fully working</title>
      <link>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275211#M21258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As Dan pointed out, shape files can't exist in geodatabase workspaces, they exist in filesystem folder workspaces.&amp;nbsp; If you are wanting to see if a certain shape file has a corresponding feature class named after it, strip off the (.shp) on the end of the name:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; shp &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;"fghgh.shp"&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fc &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;shp&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;:&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;-&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;4&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; fc
&lt;SPAN class="string token"&gt;'fghgh'&lt;/SPAN&gt;
&lt;SPAN class="operator token"&gt;&amp;gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;‍‍‍‍‍‍‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 13:25:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/help-arcpy-tool-with-if-else-statement-not-fully/m-p/275211#M21258</guid>
      <dc:creator>JoshuaBixby</dc:creator>
      <dc:date>2021-12-11T13:25:05Z</dc:date>
    </item>
  </channel>
</rss>

