<?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: Sequential Number? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556390#M43476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Rhett, I will try that!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 10 Jul 2013 19:12:26 GMT</pubDate>
    <dc:creator>ionarawilson1</dc:creator>
    <dc:date>2013-07-10T19:12:26Z</dc:date>
    <item>
      <title>Sequential Number?</title>
      <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556386#M43472</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Does anybody know if it is possible to calculate a sequential number for an attribute for a feature class that has a definition query for just one record selected? Thank you!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 12:54:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-number/m-p/556386#M43472</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-07-10T12:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential Number?</title>
      <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556387#M43473</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Not too certain what you are asking. If you need to calculate sequential numbers, simple python code in field calculator (from Arc Help):&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Calculate a sequential ID or number based on an interval.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Parser:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Python&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Expression:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;autoIncrement()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Code Block:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;rec=0&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;def autoIncrement():&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; global rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pStart = 1 #adjust start value, if req'd &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; pInterval = 1 #adjust interval value, if req'd&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; if (rec == 0): &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = pStart &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; else: &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; rec = rec + pInterval &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; return rec&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;And if you have a definition query, it will only calculate values for the selected records.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Jim&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 15:02:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-number/m-p/556387#M43473</guid>
      <dc:creator>JimCousins</dc:creator>
      <dc:date>2013-07-10T15:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential Number?</title>
      <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556388#M43474</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi Jim,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks but I am writing a script, I am not using the field calculator.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 15:07:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-number/m-p/556388#M43474</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-07-10T15:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential Number?</title>
      <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556389#M43475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Ionara,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Don't really have time to try/test this, but here is what I would try.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sort the table by the field you want to update and get the max value with &lt;/SPAN&gt;&lt;PRE class="plain" name="code"&gt;maxValue = arcpy.SearchCursor(infc, "", "", "", sortfield+" D").next().getValue("OBJECTID")&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;SPAN&gt;&amp;nbsp; or the code you have above.&amp;nbsp; However, make sure the infc is the actuall feature class, not a featurelayer.&amp;nbsp; If in tool, don't pick from dropdown list, click browse and navigate to the FC itself or hardcode in the script)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I say to use the FC itself as the selection you have is on the featureLayer (since that is what is supported) and the def query is in the mxd, so you can iterate through all the values, regardless of def query or selection if you use the FC directly. (I think this is true.&amp;nbsp; It works as stand alone, but not positive from within ArcMap, it may on the fly it again, you will have to test)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Now you have the max value, you can increment as you did above maxValue += 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You already have a selection on the feature layer, you now have the next value, so, since it is only one record that you are updating, I'd just use arcpy.CalculateField_management to update that one record.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you have multiple records in your selection, that is where I'd use your UpdateCursor, filtered to null values only AND sorted by OID (that way, they will be "sequential" relative to the order in the table).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Then just increment the maxValue each loop and updateRow.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Hope this gives you some ideas that actually help,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;R_&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 17:08:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-number/m-p/556389#M43475</guid>
      <dc:creator>RhettZufelt</dc:creator>
      <dc:date>2013-07-10T17:08:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sequential Number?</title>
      <link>https://community.esri.com/t5/python-questions/sequential-number/m-p/556390#M43476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thank you Rhett, I will try that!!!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 10 Jul 2013 19:12:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/sequential-number/m-p/556390#M43476</guid>
      <dc:creator>ionarawilson1</dc:creator>
      <dc:date>2013-07-10T19:12:26Z</dc:date>
    </item>
  </channel>
</rss>

