<?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: using python scripts in models in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310816#M24202</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You have the right idea; you're just making it more complicated than it needs to be.&amp;nbsp; Try:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management(test_poly, "X_COORD", "!Shape!.centroid.x", "PYTHON", "")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I have attached a screenshot below.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried that but it is throwing this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (Calculate Field): CalculateField BuildingTest Easting !Shape!.centroid.x PYTHON #&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 19 15:36:21 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: GPVARIANTOBJECT0.centroid.x &amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'str' object has no attribute 'x'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Field).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Wed Oct 19 15:36:21 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Oct 2011 13:40:08 GMT</pubDate>
    <dc:creator>YousafHassan</dc:creator>
    <dc:date>2011-10-19T13:40:08Z</dc:date>
    <item>
      <title>using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310812#M24198</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi I am trying to use python script in a model but it is throwing an error message:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Runtime error &amp;lt;type 'exceptions.NameError'&amp;gt;: name 'table2' is not defined&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Field).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I guess, it is about how to use table2 in the CalculateField_management function. I am not sure how I can do it.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached the screen shot of my model and the script. Any help would be really appreciated.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Oct 2011 10:51:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310812#M24198</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-18T10:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310813#M24199</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;That is not the way to use a Python script.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You were trying to put a script inside the Field Calculator. The field calculator can have some Python stuff in it, but only basic operators. What is it you want to do inside the tool? The tool you have showing IS the calculateField_management() tool that you have in your script... I.e. you can just do it directly...&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 06:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310813#M24199</guid>
      <dc:creator>StacyRendall1</dc:creator>
      <dc:date>2011-10-19T06:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310814#M24200</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to do what this example is showing in VB:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://support.esri.com/en/knowledgebase/techarticles/detail/32482"&gt;http://support.esri.com/en/knowledgebase/techarticles/detail/32482&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am trying to use python instead of VB.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 08:36:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310814#M24200</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-19T08:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310815#M24201</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;You have the right idea; you're just making it more complicated than it needs to be.&amp;nbsp; Try:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management(test_poly, "X_COORD", "!Shape!.centroid.x", "PYTHON", "")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached a screenshot below.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 12:51:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310815#M24201</guid>
      <dc:creator>ChristopherStorer</dc:creator>
      <dc:date>2011-10-19T12:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310816#M24202</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;You have the right idea; you're just making it more complicated than it needs to be.&amp;nbsp; Try:&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;arcpy.CalculateField_management(test_poly, "X_COORD", "!Shape!.centroid.x", "PYTHON", "")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;I have attached a screenshot below.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I've tried that but it is throwing this error:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Executing (Calculate Field): CalculateField BuildingTest Easting !Shape!.centroid.x PYTHON #&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Start Time: Wed Oct 19 15:36:21 2011&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;ERROR 000539: Error running expression: GPVARIANTOBJECT0.centroid.x &amp;lt;type 'exceptions.AttributeError'&amp;gt;: 'str' object has no attribute 'x'&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed to execute (Calculate Field).&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Failed at Wed Oct 19 15:36:21 2011 (Elapsed Time: 0.00 seconds)&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 13:40:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310816#M24202</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-19T13:40:08Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310817#M24203</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Well that's interesting.&amp;nbsp; You do have a shape field called Shape, I assume?&amp;nbsp; Maybe you can attach a one-record copy of this table so we can reproduce the error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 13:43:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310817#M24203</guid>
      <dc:creator>ChristopherStorer</dc:creator>
      <dc:date>2011-10-19T13:43:25Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310818#M24204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Well that's interesting.&amp;nbsp; You do have a shape field called Shape, I assume?&amp;nbsp; Maybe you can attach a one-record copy of this table so we can reproduce the error.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Yes, the Shape field is there but it is called Shape * see the attached screen shot. Also, I have attached a record for you.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 14:00:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310818#M24204</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-19T14:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310819#M24205</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;The * is okay, that just means the field is binary, which is a good thing.&amp;nbsp; The csv export you posted doesn't have a shape field, and doesn't contain the original field formats, so it doesn't help much with determining the problem.&amp;nbsp; Please see the attached screenshots for proper export technique.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2011 14:35:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310819#M24205</guid>
      <dc:creator>ChristopherStorer</dc:creator>
      <dc:date>2011-10-19T14:35:22Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310820#M24206</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Which version, 9.2, 9.3 and 10.x all have different syntax to access the shape field properties.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I recommend you instead of accessing the centroid this way, take an easier path: use the out of the box Feature To Point tool followed by the Add XY Coordinates tool.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 03:07:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310820#M24206</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2011-10-20T03:07:14Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310821#M24207</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have attached the zip which contains the shape file. Please have a look.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;The * is okay, that just means the field is binary, which is a good thing.&amp;nbsp; The csv export you posted doesn't have a shape field, and doesn't contain the original field formats, so it doesn't help much with determining the problem.&amp;nbsp; Please see the attached screenshots for proper export technique.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 08:21:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310821#M24207</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-20T08:21:42Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310822#M24208</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using 10 with an ArcView licence, so don't have access to Feature To Point tool.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Which version, 9.2, 9.3 and 10.x all have different syntax to access the shape field properties.&lt;BR /&gt;&lt;BR /&gt;I recommend you instead of accessing the centroid this way, take an easier path: use the out of the box Feature To Point tool followed by the Add XY Coordinates tool.&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2011 08:23:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310822#M24208</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-20T08:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: using python scripts in models</title>
      <link>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310823#M24209</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I changed the expression type to PYTHON_9.3 and it's working now.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 21 Oct 2011 13:57:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-python-scripts-in-models/m-p/310823#M24209</guid>
      <dc:creator>YousafHassan</dc:creator>
      <dc:date>2011-10-21T13:57:09Z</dc:date>
    </item>
  </channel>
</rss>

