Python Addins with comtypes/ArcObjects and Undo/Redo

Discussion created by kalley on Nov 13, 2013
Latest reply on Feb 27, 2014 by kalley
I believe there is a simple solution to the following dilemma.  Any insights/solutions would be greatly appreciated!

I have several Python AddIns that edit features in versioned SDE feature classes.  I want to be able to run these AddIns from ArcMap within an ongoing editing session, and to have the ability to undo/redo these edits using ArcMap???s Undo/Redo buttons.   My hope was to leverage comtypes in an AddIn to gain access to the ongoing ArcMap editing session (this works as expected), and that the AddIn edits would appear on the undo stack as long as I explicitly coded for start and stop edit operations (undo isn't working).  What else do I need to do to make addin edits undoable?  Do I need to fetch the existing Operation Stack and work with that?

This is a rough outline of the editing steps in the Addin, but I can provide the actual code and more detailed explanation if necessary:
edit = getIWorkspaceEditUsingComtypes()   #(this function returns IWorkspaceEdit successfully)
??? #(python code creating a feature using a Python Insert Cursor)

Other observations:  The addin edits are permanent even if I don???t save my edits.  However, I did notice that if I make an edit manually and then run the AddIn, hitting the Undo button undoes the manual edit and the addin edit disappears as well.