Most ObjectARX applications will not need to deal with undo and transaction management, but they should be aware of some important points:
- Undo and transaction management is performed on a per-document basis. In AutoCAD, it is controlled through (or in conjunction with) document locking.
- Whenever documents are locked for kWrite or kXWrite, a “begin command” undo bracket is written to the file, and then database and other modifications are performed. When the documents are unlocked from kWrite or kXWrite status, the corresponding “end command” undo bracket will be written. (Note that these can be nested.) By the time an application is finished operating on a document, it should have balanced its document lock and unlock requests. If the requests are not balanced, the undo file will work incorrectly, leaving actions out of sync from after the first write lock, and through the first lock balanced with an unlock. A subsequent undo request should put it back in sync.
- A parameter for establishing the command name is provided, which is displayed when an UNDO command is performed. The undo markers created are the same as for built-in AutoCAD and ObjectARX commands, and can therefore be managed via UNDO GROUP.
- Documents can have undo performed independently from each other.
- By default, when an instance of AcDbDatabase is created, its undo and transaction management is associated with the current document.
- Note that there are two methods of AcEditorReactor that are used to hook up databases with a document's undo facilities and transaction manager: databaseConstructed() and databaseToBeDestroyed(). If you receive such notification, be aware that the association between the database and any documents is undefined at that time, so document locking may or may not be required in the databaseConstructed() callback. Of course, any action that undoes any modifications done at that time will also undo the creation of the database.
- The default AcDbDatabase constructors will query the AcDbHostApplicationServices object for an undo controller.