<?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: ArcPro Calculate Field with Python Error in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579631#M92385</link>
    <description>&lt;LI-CODE lang="python"&gt;# code block
rec=0
st = 'ARC-DOOR-STN-' + "{:0&amp;gt;5}"
def SequentialNumber():
    global rec
    pStart = 669
    pInterval = 1
    if (rec == 0):
        rec = pStart
    else:
        rec = rec + pInterval
    rec = st.format(rec)
    return rec
    
# expression
SequentialNumber()
'ARC-DOOR-STN-00669'&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 28 Jan 2025 18:23:04 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2025-01-28T18:23:04Z</dc:date>
    <item>
      <title>ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579617#M92380</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to calculate a field with a constant text string and sequential numbering with leading zeros. I have used this expression and code block previously and been successful but now I am getting an error that it cannot find a function that matches the text string. Obviously, there would not be a function matching my text string, but I am not sure why it is not being recognized as a string with the ' '.&lt;/P&gt;&lt;P&gt;Any help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StephanieOosterhouse_0-1738087076725.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124173iF2871BDEE38FB6D5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StephanieOosterhouse_0-1738087076725.png" alt="StephanieOosterhouse_0-1738087076725.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Expression:&amp;nbsp;'ARC-DOOR-STN-' + "{:0&amp;gt;5}".format(SequentialNumber())&lt;/P&gt;&lt;P&gt;Code Block:&lt;/P&gt;&lt;P&gt;# Calculates a sequential number&lt;BR /&gt;# More calculator examples at esriurl.com/CalculatorExamples&lt;BR /&gt;rec=0&lt;BR /&gt;def SequentialNumber():&lt;BR /&gt;global rec&lt;BR /&gt;pStart = 669&lt;BR /&gt;pInterval = 1&lt;BR /&gt;if (rec == 0):&lt;BR /&gt;rec = pStart&lt;BR /&gt;else:&lt;BR /&gt;rec = rec + pInterval&lt;BR /&gt;return rec&lt;/P&gt;&lt;P&gt;#change pstart to last ID number#&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 17:58:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579617#M92380</guid>
      <dc:creator>StephanieOosterhouse</dc:creator>
      <dc:date>2025-01-28T17:58:58Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579624#M92382</link>
      <description>&lt;P&gt;It's probably just an Arcism if it worked before.&amp;nbsp; Easiest fix might be to just put everything into the code block return.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 18:17:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579624#M92382</guid>
      <dc:creator>DavidPike</dc:creator>
      <dc:date>2025-01-28T18:17:29Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579631#M92385</link>
      <description>&lt;LI-CODE lang="python"&gt;# code block
rec=0
st = 'ARC-DOOR-STN-' + "{:0&amp;gt;5}"
def SequentialNumber():
    global rec
    pStart = 669
    pInterval = 1
    if (rec == 0):
        rec = pStart
    else:
        rec = rec + pInterval
    rec = st.format(rec)
    return rec
    
# expression
SequentialNumber()
'ARC-DOOR-STN-00669'&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 28 Jan 2025 18:23:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579631#M92385</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2025-01-28T18:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579668#M92392</link>
      <description>&lt;P&gt;The expression is now valid but I am getting this error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="StephanieOosterhouse_0-1738093468526.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/124181iB5D52AB69870D5A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="StephanieOosterhouse_0-1738093468526.png" alt="StephanieOosterhouse_0-1738093468526.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;This seems like an easy fix but I am not sure where/how to change the int to string. Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 19:45:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579668#M92392</guid>
      <dc:creator>StephanieOosterhouse</dc:creator>
      <dc:date>2025-01-28T19:45:46Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579713#M92395</link>
      <description>&lt;P&gt;I recommend just adding prefix above the sequential code and add it in the return string. This keeps it simple, and I have used it on some hefty datasets. Check out below: you will see I was creating ID's for manholes and their district.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;prefix= "6-MH-"
rec=0
def SequentialNumber():
    global rec
    pStart = 1
    pInterval = 1
    if (rec == 0):
        rec = pStart
    else:
        rec = rec + pInterval
    return prefix + str(rec)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 20:30:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579713#M92395</guid>
      <dc:creator>Nick_Creedon</dc:creator>
      <dc:date>2025-01-28T20:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: ArcPro Calculate Field with Python Error</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579732#M92397</link>
      <description>&lt;P&gt;With a bit of adjusting I was able to add in the leading zeros using this method as well. Here is the code chunk for anyone else who might need it:&lt;/P&gt;&lt;P&gt;prefix= "ARC-ROOM-STN-"&lt;BR /&gt;rec=0&lt;BR /&gt;def SequentialNumber():&lt;BR /&gt;global rec&lt;BR /&gt;pStart = 670&lt;BR /&gt;pInterval = 1&lt;BR /&gt;if (rec == 0):&lt;BR /&gt;rec = pStart&lt;BR /&gt;else:&lt;BR /&gt;rec = int(rec) + pInterval&lt;BR /&gt;rec = "{:05}".format(rec)&lt;BR /&gt;return prefix + rec&lt;/P&gt;&lt;P&gt;#pStart equals next number in sequence&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jan 2025 20:59:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcpro-calculate-field-with-python-error/m-p/1579732#M92397</guid>
      <dc:creator>StephanieOosterhouse</dc:creator>
      <dc:date>2025-01-28T20:59:26Z</dc:date>
    </item>
  </channel>
</rss>

