<?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: rewrite a module for a toolbox script in python in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25361#M906</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ah I put that row.setValue("Cnt") in there - really I want something like the output of the previous function e.g row.setValue("Cnt",distance) but that doesn't work either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the nearpoint - 1 works when I run the script in a python window - its taking away the distance of points from a point (I think?).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 02 Oct 2011 11:01:54 GMT</pubDate>
    <dc:creator>SylviaNiderla</dc:creator>
    <dc:date>2011-10-02T11:01:54Z</dc:date>
    <item>
      <title>rewrite a module for a toolbox script in python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25359#M904</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I have the following working script - here is an exerpt &lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
rowCursor = arcpy.UpdateCursor(inputFC)
for row in rowCursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.getValue(desc.shapeFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp; from_point = geom.centroid
&amp;nbsp;&amp;nbsp;&amp;nbsp; near_pts = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; for to_point in coord_pairs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; distance = math.sqrt(pow((to_point.X - from_point.X), 2) + pow((to_point.Y - from_point.Y), 2))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if distance &amp;lt;= inputdistance:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_pts += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp; row.cnt = near_pts - 1 # Subtract 1 to remove the measurement to itself
&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCursor.updateRow(row)
del rowCursor &lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I want to add it as a toolbox script in arcmap instead of running it from the python window. I've tried to rewrite it but I keep getting an error, so its wrong somehow. I have the getparameter as text part at the start, and it keeps erroring in this part. I think its where I have placed the setValue - but I have tried to adjust it and it keeps erroring.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; rowCursor = arcpy.UpdateCursor(inputFC)
&amp;nbsp;&amp;nbsp;&amp;nbsp; for row in rowCursor:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; geom = row.getValue(desc.shapeFieldName)
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from_point = geom.centroid
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_pts = 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for to_point in coord_pairs:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.getValue = math.sqrt(pow((to_point.X - from_point.X), 2) + pow((to_point.Y - from_point.Y), 2))
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if distance &amp;lt;= inputdistance:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_pts += 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; near_pts - 1
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; row.setValue("Cnt")
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; del rowCursor&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 07:18:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25359#M904</guid>
      <dc:creator>SylviaNiderla</dc:creator>
      <dc:date>2011-10-02T07:18:50Z</dc:date>
    </item>
    <item>
      <title>Re: rewrite a module for a toolbox script in python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25360#M905</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;near_pts - 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;is wrong&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;row.setValue("Cnt")&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;will set everthing in that row to the text value&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;this line&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;del rowCursor&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;will delete the cursor on the first pass&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;additionally, the indentation after the if statement is incorrect&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 08:56:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25360#M905</guid>
      <dc:creator>DanPatterson_Retired</dc:creator>
      <dc:date>2011-10-02T08:56:11Z</dc:date>
    </item>
    <item>
      <title>Re: rewrite a module for a toolbox script in python</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25361#M906</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;ah I put that row.setValue("Cnt") in there - really I want something like the output of the previous function e.g row.setValue("Cnt",distance) but that doesn't work either.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;the nearpoint - 1 works when I run the script in a python window - its taking away the distance of points from a point (I think?).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 02 Oct 2011 11:01:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/rewrite-a-module-for-a-toolbox-script-in-python/m-p/25361#M906</guid>
      <dc:creator>SylviaNiderla</dc:creator>
      <dc:date>2011-10-02T11:01:54Z</dc:date>
    </item>
  </channel>
</rss>

