C++
Acad::ErrorStatus restoreForwardingXrefSymbols();
Description
This function must be used with restoreOriginalXrefSymbols(), and should be wrapped around all code with plans to edit and/or save Xref databases.
restoreForwardingXrefSymbols() literally redoes all the changes back to a proper Xref resolve status. Thus, if the original symbols are restored, and then changes are made to the symbols before restoreForwardingXrefSymbols(), those changes will be overwritten. However, newly added symbols will be properly resolved during restoreForwardingXrefSymbols(), and then will be included in the undo/redo of future calls to these two methods. (The only work-around to wanting to change the symbols themselves is to go ahead and make the changes, save them to disk, and then let restoreForwardingXrefSymbols() overwrite the changes. When all is done, reload the Xref from disk.)
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.
In order to properly resolve the Xref, restoreForwardingXrefSymbols() needs write access to the symbol tables and symbol table records in the host drawing. Therefore, applications should close any open symbol tables or symbol table records before calling restoreForwardingXrefSymbols().
restoreForwardingXrefSymbols() 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 eIllegalReplacement if the Xref has been reloaded since the restoreOriginalXrefSymbols() call, which should not be done. This function also may return eWasOpenForRead, eWasOpenForWrite, or eHadMultipleReaders if the calling application fails to close any open symbol tables or symbol table records before calling this function.
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.