<?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: Converting a VB script into Python in ArcGIS API for Python Questions</title>
    <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763691#M426</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whatever your trying to convert it does not look like it came from Model Builder.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used VB code in model builder expressions in the past and if they work in model builder, which I am assuming yours do, they should convert to python and the code from your last post is not python.&amp;nbsp; Or are you just posting the original VB code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 25 Oct 2019 14:23:25 GMT</pubDate>
    <dc:creator>RobertBorchert</dc:creator>
    <dc:date>2019-10-25T14:23:25Z</dc:date>
    <item>
      <title>Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763687#M422</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had some VB code in one of my Calculate Field modules in modelbuilder. I am trying to convert it to Python&lt;BR /&gt;Can anybody help me with this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF RTRIM([PRE_DIR]) = &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; then&lt;/P&gt;&lt;P&gt;MyLabel = LTRIM([STR_NAME]) &amp;amp; &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; &amp;amp; [SUF_FIX]&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;MyLabel = RTRIM([PRE_DIR]) &amp;amp; &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; &amp;amp; LTRIM(RTRIM([STR_NAME])) &amp;amp; &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; &amp;amp; [SUF_FIX]&lt;/P&gt;&lt;P&gt;end If&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2019 15:29:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763687#M422</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-24T15:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763688#M423</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If you have it in model builder simply open it in model builder.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then under Model and Export you can export it automatically to a python scrip.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="" class="jive-emoji image-1 jive-image j-img-original" src="https://community.esri.com/legacyfs/online/467703_Capture.PNG" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2019 15:32:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763688#M423</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2019-10-24T15:32:24Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763689#M424</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert! I knew there was an easy way to do this. HAHA!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 24 Oct 2019 15:36:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763689#M424</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-24T15:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763690#M425</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know I marked your response as correct and it may be correct but I'm still getting an error when trying to convert my if statement to python. I tried this but it isn't working&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (!PRE_DIR!).RTrim() = &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #6c71c4;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;print&lt;/SPAN&gt;(!STR_NAM!) + &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; + (!SUF_FIX!)&lt;/P&gt;&lt;P&gt;else&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #6c71c4;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;print&lt;/SPAN&gt;(!PRE_DIR!).RTrim() + &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; + LTrim (RTrim(!STR_NAME!)) + &lt;SPAN style="color: #e42e30;"&gt;" "&lt;/SPAN&gt; +&lt;/P&gt;&lt;P&gt;Return !SUF_FIX!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:15:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763690#M425</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-25T14:15:35Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763691#M426</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Whatever your trying to convert it does not look like it came from Model Builder.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have used VB code in model builder expressions in the past and if they work in model builder, which I am assuming yours do, they should convert to python and the code from your last post is not python.&amp;nbsp; Or are you just posting the original VB code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:23:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763691#M426</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2019-10-25T14:23:25Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763692#M427</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know I have the syntax wrong because I am very unfamiliar with python syntax. I have just been looking at python examples on the internet and doing what I thought would work since what I had in VB works. Here is a screenshot of the Calculate Field module I have in python.&lt;/P&gt;&lt;P&gt;&lt;IMG alt="Calculate Field module" class="jive-emoji image-1 jive-image j-img-original" src="/legacyfs/online/467785_Calculate Field error.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:33:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763692#M427</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-25T14:33:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763693#M428</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What does the syntax look like when you open the python script after you export it as python&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:53:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763693#M428</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2019-10-25T14:53:40Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763694#M429</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;# Process: Calculate Field (2)&lt;BR /&gt;arcpy.CalculateField_management(clines__5_, "LABEL", "RTRIM([PRE_DIR]) &amp;amp; \" \" &amp;amp; LTRIM(RTRIM([STR_NAME])) &amp;amp; \" \" &amp;amp; [SUF_FIX]", "VB", "IF RTRIM([PRE_DIR]) = \" \" then\\n&amp;nbsp;&amp;nbsp;&amp;nbsp; MyLabel = LTRIM([STR_NAME]) &amp;amp; \" \" &amp;amp; [SUF_FIX]\\nelse\\n&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 14:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763694#M429</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-25T14:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763695#M430</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That looks like it should work when you run the python script.&amp;nbsp; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:00:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763695#M430</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2019-10-25T15:00:54Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763696#M431</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Then I just need to learn how to enter it into the prelogic part of the module.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for helping me figure out this issue Robert!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:04:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763696#M431</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-25T15:04:56Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763697#M432</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have been able to accomplish some pretty cool things by exporting a model to python.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I had to figure out a way to import 6 feature classes from 1400 file geodatabases that all had the same name that were exports from StakeOut (a software for marking utility lines)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I made a model that would do it for one of the databases. Exported it to python.&amp;nbsp; Took the python script into MS Access and pasted it in to a Long Text Field.&amp;nbsp; I then put in the variations of the database names in another table and joined them together. Did a find replace to insert the variables, added the Del function at end.&amp;nbsp; Pasted the new script back into python and went from there.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So my next question is.&amp;nbsp; Is this a script that will run more than once?&amp;nbsp; If so you need add the Del function at the end of the script to reset the variables.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:21:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763697#M432</guid>
      <dc:creator>RobertBorchert</dc:creator>
      <dc:date>2019-10-25T15:21:16Z</dc:date>
    </item>
    <item>
      <title>Re: Converting a VB script into Python</title>
      <link>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763698#M433</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes this is a script which I will have to run occasionally. I still have ArcMap 10.7 on my computer so I'm not completely devoid of using my old way of running the script in VB. I'm just slowly trying to learn how to do it in Python in case in the future I lose my connection with ArcMap and have to rely on using ArcGIS Pro.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hopefully I never have to get that complex in scripting. That's a clever way of using other programs to figure out how to accomplish a complex task!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 25 Oct 2019 15:34:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-api-for-python-questions/converting-a-vb-script-into-python/m-p/763698#M433</guid>
      <dc:creator>SLouq</dc:creator>
      <dc:date>2019-10-25T15:34:30Z</dc:date>
    </item>
  </channel>
</rss>

