I have a series of different Feature Classes and most of them I have assigned a Company Tag/Number and they are in sequential order. What I would like to do is to write a Python script to identify what the next number would be on a given Feature Class's field. If the last sequential number of 2345, I would want the script to "print" 2346. Need to know how to get started.
Want to write a Python script to achieve this.
Thank You
Solved! Go to Solution.
Perhaps something like this would give you an idea. It is using the OBJECTID; just substitute your tag number field in lines 1 and 2:
value = arcpy.da.SearchCursor(feature, ["OBJECTID"],
sql_clause = (None, 'ORDER BY OBJECTID DESC')
).next()[0]
print value
# 19
print value + 1
# 20
If the tag numbers are spread across several features - that is number 1, 3, 4, etc. can be in one feature, and 2, 5 are in another - you may need to use a table or text file to store the last number used. Then read that table/file, issue tag numbers, then update the table/file with the last used number.
Perhaps something like this would give you an idea. It is using the OBJECTID; just substitute your tag number field in lines 1 and 2:
value = arcpy.da.SearchCursor(feature, ["OBJECTID"],
sql_clause = (None, 'ORDER BY OBJECTID DESC')
).next()[0]
print value
# 19
print value + 1
# 20
If the tag numbers are spread across several features - that is number 1, 3, 4, etc. can be in one feature, and 2, 5 are in another - you may need to use a table or text file to store the last number used. Then read that table/file, issue tag numbers, then update the table/file with the last used number.
Thank You Randy. That is what I was looking for.