Document-Independent Databases

To participate in undo in AutoCAD, databases must be associated with a document, because each document has an independent undo stack. However, this feature is in direct conflict with the need to load databases whose contents are intended to be shared across document edit sessions. In other words, you must decide between the following two scenarios for your side databases:

In ObjectARX, the former scenario is the default. Whenever a new instance of AcDbDatabase is instantiated, it is associated with the current document. This is one of the reasons an application needs to change the current document without activating the new document.

The AcDbDatabase class provides the following function, which disables the database undo and disassociates the database from the document:

void
disableUndoRecording(
    bool disable);

Any AcDb reliance on any document-specific system variables will assume the built-in defaults for document-independent databases. Also, there is no need to lock any documents to access document-independent databases.

Note: Developers who think about triggering an independent undo controller from multiple document undo controllers should remain aware that performing undo in a given document can lead to inconsistency and corruption. For example: Database X has an undo controller not associated with any document. Modifications from Document A are made to Database X, then modifications from Document B, which rely on objects created or modified from the Document A modifications. Now, undo is applied in Document A. The changes made to Document B will be corrupted.