C++
Acad::ErrorStatus restoreOriginalXrefSymbols();
Description
This function must be used with restoreForwardingXrefSymbols(), and should be wrapped around all code with plans to edit and/or save Xref databases.
The restoreOriginalXrefSymbols() method undoes all the changes the database did during its resolve, so that the database is now in the same condition it was when it was first read in from its file.
The symbols affected are the Table and Records for blocks, layers, linetypes, text styles, dimension styles, registered applications, and plot styles, as well as any custom object changes made during and between the beginAttach() and otherAttach() notifications.
restoreOriginalXrefSymbols() returns eLockViolation if the document the database belongs to is not locked, eNotApplicable if the database is not an active Xref database or if called from within the beginAttach() or otherAttach() callbacks, or eAlreadyInDb if the symbols are already restored.
These methods are also normally used with the AcEdXrefFileLock class. The following code snippet is an example of using these methods:
AcEdXrefFileLock flock; flock.lockFile(stat, pXrefDb->xrefBlockId()); pXrefDb->restoreOriginalXrefSymbols() // Make changes, or add objects flock.releaseFile(stat); // Does the saveback pXrefDb->restoreForwardingXrefSymbols();
Normally, releaseFile() will call the restore functions automatically, but it skips the calls if the restoration has already been done. Putting the restoreForwardingXrefSymbols() call after the call to releaseFile() saves having multiple calls to restore the symbols.