When an object is added, modified or deleted from the drawing, a common scenario consist in write that information to an XML file by using the ObjectAdded and ObjectErased events of the database reactor. But when UNDO and REDO commands are used in between, these events did not work. Is there any way to handle this situation with reactors?
In this situation, two reactors need to be used, one is document reactor and the other is database reactor. For example, monitor two events of the document, CommandWillStart and CommandEnded to know when the UNDO/REDO command is going to start and when it ends. Then in the events of the current database, ObjectReappended and ObjectUnappended, make records what objects have been unappended or reappended.
Then in the CommandEnded event of the current document iterate through those recorded objects, check if some particular information you want and do any other operations if necessary such as updating your XML file.
Generally speaking, avoid manipulating objects and database in any events other than CommandEnded since the current database is most of times in a flux state and related objects are already in read/write mode.