Flushing the Undo Buffer
 
 
 

If a plug-in developer needs to clear the undo buffer, two API functions are available to do so. The method Interface::FlushUndoBuffer() and the global function: GetSystemSetting() with the ID SYSSET_CLEAR_UNDO as a parameter.

An example of when to do this is when a creation object is deleted after some undo items have been put on the stack that refer to that object, for instance when a plug-in is doing a custom creation process. See the sample code in \MAXSDK\SAMPLES\OBJECTS\LIGHT.CPP.

If the creation object is deleted without being attached to a node, or if the creation is canceled, and if some undo objects have been logged since the creation object was created, then one should flush the entire undo stack. This is the only way to ensure that the 3ds Max undo stack is not corrupt with restore objects that point to deleted objects.