<?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: ArcToolbox scripts behave differently then the hard-coded versions. in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43603#M3433</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gerry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you probably need to post more of your code. The error message you are receiving indicates that the geometry is not actually an object - just a string (some text), in this case a Unicode string, which is how the parameters from Arc are brought in...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do some testing with arcpy.AddMessage() just before the line that is failing, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(str(geometry1)+type(geometry1))&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then test this in both situations and check it is the same...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Oct 2011 18:39:44 GMT</pubDate>
    <dc:creator>StacyRendall1</dc:creator>
    <dc:date>2011-10-14T18:39:44Z</dc:date>
    <item>
      <title>ArcToolbox scripts behave differently then the hard-coded versions.</title>
      <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43602#M3432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I made a four color map algorithm for Python. When I execute the script in PythonWin, Komodo, or Idle, with the path to the feature class hard-coded into the script, things run fine. I know the syntax is correct. Once I add the script to ArcToolbox it throws an error (error message posted below). The error occurs at this line.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;if (geometry1.touches(geometry2) or geometry1.overlaps(geometry2)) and counter != counter1: &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;File "E:\SCRIPT~1\MINIMU~1\minimumpolygoncolor.py", line 46, in &amp;lt;module&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (geometry1.touches(geometry2) or geometry1.overlaps(geometry2)) and counter != counter1:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Error Info:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;'unicode' object has no attribute 'touches'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ArcPy ERRORS:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I also developed a tool to remap data paths in an mxd. Again, things run fine if I post the code into the Python window. All the broken links are fixed. When I convert this tool to a Toolbox script, the paths get updated...and then removed from the mxd.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Does anyone know why a script would act differently once they are brought into ArcToolbox?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 18:11:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43602#M3432</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2011-10-14T18:11:49Z</dc:date>
    </item>
    <item>
      <title>Re: ArcToolbox scripts behave differently then the hard-coded versions.</title>
      <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43603#M3433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gerry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;you probably need to post more of your code. The error message you are receiving indicates that the geometry is not actually an object - just a string (some text), in this case a Unicode string, which is how the parameters from Arc are brought in...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You can do some testing with arcpy.AddMessage() just before the line that is failing, for example:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.AddMessage(str(geometry1)+type(geometry1))&lt;/PRE&gt;&lt;BR /&gt;&lt;SPAN&gt;You can then test this in both situations and check it is the same...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 18:39:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43603#M3433</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-10-14T18:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: ArcToolbox scripts behave differently then the hard-coded versions.</title>
      <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43604#M3434</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here is a portion of the code that returns the error.&amp;nbsp; Again, it works fine as a stand alone where it is taking the inFC as text just like the arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "go"
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy, os, sys, string, traceback, operator
&amp;nbsp;&amp;nbsp;&amp;nbsp; inFC = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; g1 = arcpy.Geometry()
&amp;nbsp;&amp;nbsp;&amp;nbsp; geometrylist1 = arcpy.CopyFeatures_management(inFC, g1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; g2 = arcpy.Geometry()
&amp;nbsp;&amp;nbsp;&amp;nbsp; geometrylist2 = arcpy.CopyFeatures_management(inFC, g2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;nbsp;&amp;nbsp;&amp;nbsp; for geometry1 in geometrylist1:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; for geometry2 in geometrylist2:
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (geometry1.touches(geometry2) or geometry1.overlaps(geometry2)):
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; print "Do more stuff here..."
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "done"
except arcpy.ExecuteError:
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = arcpy.GetMessages(2) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs) 
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs
except:
&amp;nbsp;&amp;nbsp;&amp;nbsp; tb = sys.exc_info()[2]
&amp;nbsp;&amp;nbsp;&amp;nbsp; tbinfo = traceback.format_tb(tb)[0]
&amp;nbsp;&amp;nbsp;&amp;nbsp; pymsg = "PYTHON ERRORS:\nTraceback info:\n" + tbinfo + "\nError Info:\n" + str(sys.exc_info()[1])
&amp;nbsp;&amp;nbsp;&amp;nbsp; msgs = "ArcPy ERRORS:\n" + arcpy.GetMessages(2) + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(pymsg)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddError(msgs)
&amp;nbsp;&amp;nbsp;&amp;nbsp; print pymsg + "\n"
&amp;nbsp;&amp;nbsp;&amp;nbsp; print msgs&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:40:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43604#M3434</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2021-12-10T21:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: ArcToolbox scripts behave differently then the hard-coded versions.</title>
      <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43605#M3435</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Stacy, thanks for the tip. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; When I run the tool in Komodo I get this for the str(geometry1)&amp;nbsp; and type(geometry 1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;geoprocessing describe geometry object object at 0x0ECA3D28&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;class 'arcpy.arcobjects.geometries.Polygon'&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;geoprocessing describe geometry object object at 0x0ECA3D28&amp;gt;&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;In ArctoolBox I get this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;lt;type 'unicode'&amp;gt;&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Oct 2011 20:33:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43605#M3435</guid>
      <dc:creator>GerryGabrisch</dc:creator>
      <dc:date>2011-10-14T20:33:11Z</dc:date>
    </item>
    <item>
      <title>Re: ArcToolbox scripts behave differently then the hard-coded versions.</title>
      <link>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43606#M3436</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Gerry,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;try putting &lt;/SPAN&gt;&lt;STRONG style="font-style: italic;"&gt;AddMessage()&lt;/STRONG&gt;&lt;SPAN&gt; comments after every operation. There is a good chance that your input isn't coming through quite as you expect it. I.e. make the top part of your code like so:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;try:
&amp;nbsp;&amp;nbsp;&amp;nbsp; print "go"
&amp;nbsp;&amp;nbsp;&amp;nbsp; import arcpy, os, sys, string, traceback, operator
&amp;nbsp;&amp;nbsp;&amp;nbsp; inFC = arcpy.GetParameterAsText(0)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(inFC)+str(type(inFC)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; g1 = arcpy.Geometry()
&amp;nbsp;&amp;nbsp;&amp;nbsp; geometrylist1 = arcpy.CopyFeatures_management(inFC, g1)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(geometrylist1)+str(type(geometrylist1)))
&amp;nbsp;&amp;nbsp;&amp;nbsp; g2 = arcpy.Geometry()
&amp;nbsp;&amp;nbsp;&amp;nbsp; geometrylist2 = arcpy.CopyFeatures_management(inFC, g2)
&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.AddMessage(str(geometrylist2)+str(type(geometrylist2)))

&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Dec 2021 21:40:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arctoolbox-scripts-behave-differently-then-the/m-p/43606#M3436</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2021-12-10T21:40:10Z</dc:date>
    </item>
  </channel>
</rss>

