Trying to populate certain attributes as soon as a feature is created. I have tried the python add-in application extension function "onCreateFeature", which does get triggered when a feature is created. The new feature remains selected in the display and table, but then when I execute a "describe" or Search/UpdateCursor within the onCreateFeature class it returns the selection that existed before the feature was digitized. (eg: feature OID 12 is digitized and remains selected/highlighted, but describe and cursor see OID 11 as the current selection.) Any suggestions as to what's wrong here?
class UpdateNewFeature(object):
"""Implementation for listener3cursor_addin.ext3 (Extension)"""
def __init__(self):
self.enabled = True
def onCreateFeature(self):
TESTline_Lyr = "TESTlines"
TESTline_Fields = ['OBJECTID','NewAttrib','SHAPE_Length']
# count selected features
d = arcpy.Describe(TESTline_Lyr)
if len(d.FIDSet) == 0:
TESTline_Select = 0
else:
TESTline_Select = len(d.FIDSet.split(";"))
print "OID:",FIDSet
with arcpy.da.UpdateCursor(TESTline_Lyr,TESTline_Fields) as cursor:
for row in cursor:
print "ROW:", row
# and update a few attributes based on current conditions