I would like to take sequential numbers up a level and only apply it to features of a certain type. Say I have two feature types, black and white features, and it's denoted by the field "Type". I want my sequential numbers code to skip all white features and pick up where it left off with the last black feature. I'm sure it's some type of If/Then statement but i can't figure it out. Here's the basic code where it returns sequential numbers by my sort field, which works just fine:
import arcpy
sortFeat = r"P:\path\Receivers.shp" #featurepath
sortField = 'Ycoord' #Base Field to sort, which is
idField = 'R_ID' #Field to populate sequential numbers
rec=0
def autoIncrement():
global rec
pStart = 36 #number of features
pInterval = 1
if (rec == 0):
rec = pStart
else:
rec -= pInterval
return "R" + str(rec)
rows = arcpy.UpdateCursor(sortFeat, "", "", "", sortField)
for row in rows:
row.setValue(idField, autoIncrement())
rows.updateRow(row)
del row, rows
print "Finish"
So how can i make this only apply to certain attribute type and not all within the layer?
I am using Python 3, but this currently only works in a 2.7 environment.