<?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: autoIncrement block not working within a Python Toolbox? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176204#M64618</link>
    <description>&lt;P&gt;If you right click on TestToolbox.pyt do you get an option to "Check Syntax"?&lt;/P&gt;</description>
    <pubDate>Sun, 22 May 2022 00:09:09 GMT</pubDate>
    <dc:creator>DonMorrison1</dc:creator>
    <dc:date>2022-05-22T00:09:09Z</dc:date>
    <item>
      <title>autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176198#M64614</link>
      <description>&lt;P&gt;Hey guys. I am creating a python toolbox that assigns selected polygons in a shapefile a unique id. This id features a section of string followed by a sequential ID. However, whenever I insert the following code block for autoIncrement into my script, the tool will no longer launch. This is the autoincrement block I have taken from ArcGIS Resources:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;        rec = 0
def autoIncrement():
 global rec
 pStart = 1 #adjust start value, if req'd 
 pInterval = 1 #adjust interval value, if req'd
 if (rec == 0): 
  rec = pStart 
 else: 
  rec = rec + pInterval 
 return rec&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am placing it in the " def execute(self, parameters, messages):" section of the python toolbox template.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideas as to why this is causing my script to fail? Thank you!&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2022 23:24:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176198#M64614</guid>
      <dc:creator>DPG</dc:creator>
      <dc:date>2022-05-21T23:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176199#M64615</link>
      <description>&lt;P&gt;It would be most helpful if you could post the error message, as well as the complete python file. I don't think there is anything wrong with the snippet you posted so there must be something else. Thanks&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2022 23:51:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176199#M64615</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-05-21T23:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176202#M64616</link>
      <description>&lt;P&gt;I'm afraid there is no error message. Where I can usually select the script (seen here as "Tool")...&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DPG_0-1653177180142.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41883i785EE64C8CCA7D62/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DPG_0-1653177180142.png" alt="DPG_0-1653177180142.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;... After pasting in that code block into the script, the option disappears as shown here:...&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DPG_1-1653177236107.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41884i0C4079C2386A2375/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DPG_1-1653177236107.png" alt="DPG_1-1653177236107.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 May 2022 23:54:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176202#M64616</guid>
      <dc:creator>DPG</dc:creator>
      <dc:date>2022-05-21T23:54:04Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176204#M64618</link>
      <description>&lt;P&gt;If you right click on TestToolbox.pyt do you get an option to "Check Syntax"?&lt;/P&gt;</description>
      <pubDate>Sun, 22 May 2022 00:09:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176204#M64618</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-05-22T00:09:09Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176206#M64619</link>
      <description>&lt;P&gt;Here's the error:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DPG_0-1653178801474.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/41885iCB711C575E71138C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DPG_0-1653178801474.png" alt="DPG_0-1653178801474.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context, here's this part of the code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;    def execute(self, parameters, messages):

        # Sequential Formula

        rec = 0
        def autoIncrement():
            global rec
            pStart = 1 #adjust start value, if req'd
            pInterval = 1 #adjust interval value, if req'd
            if (rec == 0):
                rec = pStart
                else:
                    rec = rec + pInterval 
        return rec&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Apologies for the lack of clarity. Line 112 is line 12 in my pasted code.&lt;/P&gt;</description>
      <pubDate>Sun, 22 May 2022 00:23:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176206#M64619</guid>
      <dc:creator>DPG</dc:creator>
      <dc:date>2022-05-22T00:23:03Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176207#M64620</link>
      <description>&lt;P&gt;Ah - now I see.&amp;nbsp; Lines 12&amp;nbsp; and 13 are indented incorrectly.&lt;/P&gt;</description>
      <pubDate>Sun, 22 May 2022 00:56:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176207#M64620</guid>
      <dc:creator>DonMorrison1</dc:creator>
      <dc:date>2022-05-22T00:56:03Z</dc:date>
    </item>
    <item>
      <title>Re: autoIncrement block not working within a Python Toolbox?</title>
      <link>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176208#M64621</link>
      <description>&lt;P&gt;Wow, how foolish of me. Thank you! Think I've been staring at code for too long.&lt;/P&gt;</description>
      <pubDate>Sun, 22 May 2022 01:03:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/autoincrement-block-not-working-within-a-python/m-p/1176208#M64621</guid>
      <dc:creator>DPG</dc:creator>
      <dc:date>2022-05-22T01:03:18Z</dc:date>
    </item>
  </channel>
</rss>

