I have written a Python add-in extension for ArcMap 10.6, I want it to automatically update some attributes after a feature is edited or created. My test code looks like this:
def onStopOperation(self):
print("%d onStopOperation(self)" % self.count)
self.count += 1
print("Workspace ", self.editWorkspace)
print("Selected ", self.editSelection)
print("currentLayer", self.currentLayer)
obj = pythonaddins.GetSelectedTOCLayerOrDataFrame()
print("current toc", obj)
My add-in catches ALL available events, and it looks like currentLayer is set to None everywhere not just in onStopOperation.
This is typical output
16 onStopOperation(self)
Workspace C:\GeoModel\Clatsop\WorkFolder\ORMAP_Clatsop.gdb
Selected [32183]
currentLayer None
current thing Taxlot
I would potentially be able to search the TOC for layer "Taxlot" but if someone clicks on another layer or edits a feature in a different layer it won't match up. I still need currentLayer to return an actual value for this to work smoothly.
I searched for some other way to detect what feature class is being edited, for example properties and methods on the map document object and on the layer objects but I don't see anything.
Since this seems like a bug to me I also filed it with ESRI, but I don't really want to wait until a release comes out, I need a work around.
I did end up getting this filed as a bug.
BUG-000113895 : current.Layer does not output the active layer being edited.
My workaround ended up being to use the Attribute Assistant add-on.