Thank you. That worked perfectly.
The use case is to temporarily color code any object in the drawing selected by the user and given a user assigned custom status. When the app window is closed, all the drawing objects shall revert to their normal colors. When the app is opened, it shall restore the saved status colors for the drawing, etc.
As I understand, this can also be done via overrules but it has proven to be much more difficult to implement properly on a per selected object(s) bases, especially when the selection may include multi-level blocks, leaders, or dimensions. I have opted to simply change the color properties of the objects instead, and revert the colors back to their stored original values on app close.
Saving of the drawing can be disabled, as the app saves it's own content in an external database.
Below is the code that worked for me based on your suggestion.
private List<string> commandsToVeto = new List<string>() { "QSAVE", "SAVE", "SAVEAS", "SAVEALL" };
documentManager.DocumentLockModeChanged += DocumentManager_DocumentLockModeChanged;
// Disable saving while app is running in order to protect the user from accidentally
// saving temporary working colors to the drawing file.
private void DocumentManager_DocumentLockModeChanged(object sender, DocumentLockModeChangedEventArgs e)
{
foreach(var command in commandsToVeto)
{
if (e.GlobalCommandName == command)
{
e.Veto();
System.Windows.MessageBox.Show("Save is disabled while the model check app is running.\nPlease close the model check window to save.");
}
}
}
Thanks again.