<?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: Issue with script tool in Transportation Questions</title>
    <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496396#M1657</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: davidisraelitt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bumping this back to the top.... Issue still exists...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 23 Aug 2013 19:32:40 GMT</pubDate>
    <dc:creator>Anonymous User</dc:creator>
    <dc:date>2013-08-23T19:32:40Z</dc:date>
    <item>
      <title>Issue with script tool</title>
      <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496393#M1654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: davidisraelitt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Background: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I have forest data stored as points and polygons. The points are the location of sample plots, and the polygons are management stands. There is a field, "SID", in the attribute table of the points that corresponds to the polygon that contains each point. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The purpose of this script tool is to update the "SID" field in the point file after the polygons have been moved (because the plot is now in a new stand). For points not within a polygon, I've set it up so they get "flagged".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Problem:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;The script will only work properly one time unless I close/reopen the mxd or start/end an edit session. The tool will run a second time, but will not perform any field recalculations or throw up an error message. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Is there something I am overlooking?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks in advance for your help!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import arcpy from arcpy import env&amp;nbsp; arcpy.AddMessage('Identifying parameters') stand = arcpy.GetParameterAsText(0) #stand polygon data sid = arcpy.GetParameterAsText(1) #unique stand identifier text field from stand layer pts = arcpy.GetParameterAsText(2) #plot points data p_sid = arcpy.GetParameterAsText(3) #unique stand identifier text field from point layer arcpy.AddMessage('Parameters identified.')&amp;nbsp; env.workspace = pts&amp;nbsp; #adds each SID to a list and looks for repeats of an SID arcpy.AddMessage('Identifying stands...') cursor1 = arcpy.da.SearchCursor(stand, [sid]) list1 = [] t = 0 for row in cursor1:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; global t &amp;nbsp;&amp;nbsp;&amp;nbsp; step1 = str(row) &amp;nbsp;&amp;nbsp;&amp;nbsp; step2 = step1.split("'")[1] &amp;nbsp;&amp;nbsp;&amp;nbsp; if list1.count(str(step2))==0:&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; list1.append(step2) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; t+=1 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if t == 1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Identified "+str(t)+" stand...") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage("Identified "+str(t)+" stands...") &amp;nbsp;&amp;nbsp;&amp;nbsp; else: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('!!!!Error: Stand ID (SID) "'+str(step2)+'" occurs '+str(list1.count(step2)+1)+' times!!!!') &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; import sys &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sys.exit(0) del cursor1&amp;nbsp; #For each SID, selects points within the stand and updates the SID of those points arcpy.AddMessage('Assigning stand ID (SID) to points...') if len(list1) &amp;gt; 0: &amp;nbsp;&amp;nbsp;&amp;nbsp; for row in list1: &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(stand, "NEW_SELECTION", str(sid)+"='"+str(row)+"'") &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(pts, "WITHIN", stand,) &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(pts, p_sid, '"'+str(row)+'"', "PYTHON")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Flagging points outside of stands...') &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(stand, "NEW_SELECTION", '"OBJECTID" &amp;gt;= 0') &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(pts, "NEW_SELECTION", '"OBJECTID" &amp;gt;= 0') &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByLocation_management(pts, "WITHIN", stand, "", "REMOVE_FROM_SELECTION") &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.CalculateField_management(pts, p_sid, '"FLAGGED_" + !'+str(p_sid)+'!', "PYTHON")&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(pts, "NEW_SELECTION", '"OBJECTID" &amp;lt; 0') &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SelectLayerByAttribute_management(stand, "NEW_SELECTION", '"OBJECTID" &amp;lt; 0') else: &amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage('Issue...')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Apr 2013 20:38:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496393#M1654</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-04-26T20:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with script tool</title>
      <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496394#M1655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: scoggins&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you tried &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;arcpy.env.overwriteOutput = True&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Put that at the beginning of the code and you'll overwrite the data you've already written with new or the same values.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 28 Apr 2013 01:09:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496394#M1655</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-04-28T01:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with script tool</title>
      <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496395#M1656</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: davidisraelitt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Have you tried &lt;BR /&gt;&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;BR /&gt;&lt;BR /&gt;?&lt;BR /&gt;&lt;BR /&gt;Put that at the beginning of the code and you'll overwrite the data you've already written with new or the same values.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I placed this above the part of my code where I define the parameters. Still no luck...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Apr 2013 11:33:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496395#M1656</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-04-30T11:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with script tool</title>
      <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496396#M1657</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Original User: davidisraelitt&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Bumping this back to the top.... Issue still exists...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 19:32:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496396#M1657</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2013-08-23T19:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: Issue with script tool</title>
      <link>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496397#M1658</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi there,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;at the end of the script i would delete all your defined variables so that none are kept in memory within your arcmap session.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you could also try using an update cursor rather than calculate field&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;hope this helps&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Tim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 Aug 2013 20:37:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/transportation-questions/issue-with-script-tool/m-p/496397#M1658</guid>
      <dc:creator>TimDonoyou</dc:creator>
      <dc:date>2013-08-23T20:37:08Z</dc:date>
    </item>
  </channel>
</rss>

