<?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: Convert VBA to Python field calculator script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34028#M2648</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread continues (several months later) here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/516328"&gt;Move point features based on XY values&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 07 May 2015 03:29:31 GMT</pubDate>
    <dc:creator>curtvprice</dc:creator>
    <dc:date>2015-05-07T03:29:31Z</dc:date>
    <item>
      <title>Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34022#M2642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I have been using this VBA field calculator script in ArcGIS 9.3.1 to shift points spatially according to the X &amp;amp; Y fields from a table join:&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim pPoint As IPoint&lt;/P&gt;&lt;P&gt;Set pPoint = [Shape]&lt;/P&gt;&lt;P&gt;pPoint.X = &lt;X&gt;&lt;/X&gt;&lt;/P&gt;&lt;P&gt;pPoint.Y = &lt;Y&gt;&lt;/Y&gt;&lt;/P&gt;&lt;P&gt;__esri_field_calculator_splitter__&lt;/P&gt;&lt;P&gt;pPoint&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it does not work in after I upgraded to ArcGIS 10.2.2. Is there anyone who is able to convert this VBA script to Python?&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Siyang&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 01:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34022#M2642</guid>
      <dc:creator>SiyangTeo</dc:creator>
      <dc:date>2014-10-16T01:29:22Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34023#M2643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I found a Python script that does the work, however, it can only shift when the XY fields are within the shapefiles, but does not work when reading from fields of a table join.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Anyone knows how to rectify this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;def pointMove(shape,x_value,y_value):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; point = shape.getPart(0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; point.X = x_value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; point.Y = y_value&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; return point&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;__esri_field_calculator_splitter__&lt;/P&gt;&lt;P&gt;pointMove( !Shape!, !X!, !Y! )&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 04:07:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34023#M2643</guid>
      <dc:creator>SiyangTeo</dc:creator>
      <dc:date>2014-10-16T04:07:36Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34024#M2644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;&amp;gt; it does not work in after I upgraded to ArcGIS 10.2.2.&lt;/EM&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;You must have updated from 9.3. The field Calculator no longer supports VBA, it now only supports VBScript and Python. You must use Python to access geometry as of ArcGIS 10.0. &lt;/SPAN&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;There are shortcuts that work with the Python syntax (i.e. "SHAPE@" for the shape field). See &lt;A href="http://resources.arcgis.com/en/help/main/10.2/index.html#//00170000004s000000"&gt;the examples in the help&lt;/A&gt;‌.&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;&amp;gt; &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;does not work when reading from fields of a table join.&lt;/SPAN&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;If the X and Y were joined fields, you'd need to uses prefixes, see below. Is that not working?&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;If anyone was wondering, the text snippet we've been sharing here is a .cal file such as what you can write from the right click field / calculate field dialog box access from a table view in ArcMap. &lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;The "__esri_field_calculator_splitter__" line separates the code block from the Calculate Field expression.&lt;/SPAN&gt; &lt;/EM&gt;&lt;/P&gt;&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&lt;EM&gt;Kind of an 8.x-ish interface ... but it is still supported.&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14134406004734083" jivemacro_uid="_14134406004734083"&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;def pointMove(shape,x_value,y_value):&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; point = shape.getPart(0)&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; point.X = x_value&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; point.Y = y_value&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;&amp;nbsp;&amp;nbsp; return point&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;__esri_field_calculator_splitter__&lt;/P&gt;
&lt;P style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;pointMove( !SHAPE@!, !jtable.X!, !jtable.Y! )&lt;/P&gt;


&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/migration-blogpost/1070"&gt;Posting Code blocks in the new GeoNet&lt;/A&gt;&lt;SPAN style="font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;‌&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 06:29:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34024#M2644</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-10-16T06:29:21Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34025#M2645</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the reply. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can I clarify; let's say my joined field names for X &amp;amp; Y are Temp.X_Point &amp;amp; Temp.Y_Point respectively (Temp being the joined layer/table name). Should the resulting expression be:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;pointMove( !SHAPE@!, !jtable.Temp.X_Point!, !jtable.Temp.Y.Point! )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;OR&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000; font-family: Consolas, 'Courier New', Courier, mono, serif; font-size: 12px; background-color: #f6f6f6;"&gt;pointMove( !SHAPE@!, !jtable.X_Point!, !jtable.Y.Point! )&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried both but the field calculator was unable to execute.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Oct 2014 08:03:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34025#M2645</guid>
      <dc:creator>SiyangTeo</dc:creator>
      <dc:date>2014-10-16T08:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34026#M2646</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;jtable was my example table name:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="python" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14135137944553415 jive_text_macro" jivemacro_uid="_14135137944553415"&gt;
&lt;P&gt;pointMove( !SHAPE@!, !Temp.X_Point!, !Temp.Y_Point! )&lt;/P&gt;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 02:43:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34026#M2646</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2014-10-17T02:43:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34027#M2647</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Price,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have changed the join table field names.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, there was an error message at the geoprocessing results window, saying "Invalid field SHAPE@".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;After changing the shape field to the actual field name, another error appeared, saying "invalid syntax (&amp;lt;string&amp;gt;, line 1)".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Wonder how to rectify from here... would you know?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for spending time with this issue btw. &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Oct 2014 16:26:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34027#M2647</guid>
      <dc:creator>SiyangTeo</dc:creator>
      <dc:date>2014-10-17T16:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Convert VBA to Python field calculator script</title>
      <link>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34028#M2648</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This thread continues (several months later) here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/message/516328"&gt;Move point features based on XY values&lt;/A&gt;​&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 07 May 2015 03:29:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/convert-vba-to-python-field-calculator-script/m-p/34028#M2648</guid>
      <dc:creator>curtvprice</dc:creator>
      <dc:date>2015-05-07T03:29:31Z</dc:date>
    </item>
  </channel>
</rss>

