Clearing the AutoCAD/IJCAD UNDO History

Asked 1 years ago, Updated 1 years ago, 82 views

  • We are currently developing the ability to update multiple drawings.
  • Specifies CommandFlags.Session to cross the drawing.

I am trying to clear the UNDO history so that I cannot return the updated information, but the CommandFlags.Session feature does not seem to work properly with Document.Editor.Command or acedCmd.

Therefore, we clear the UNDO history by Document.SendStringToExecute with the argument "UNDO UNDO A" to disable and re-enable UNDO.

However, in this way, even if CMDECHO is turned off, the command line displays the action.
Also, UNDO remains in the command line history.

Could you tell me how to deal with the following two points?

SendStringToExecute is fine, so please take care of me.

ijcad

2022-09-30 19:55

1 Answers

AutoCAD does not leave a history of UNDO commands on the command line when CMDECHO is off by invoking the following commands:

 CommandMethod("TESTCMD", CommandFlags.Session)
public void TestCommand()
{
    UndoClear();
}

private static async void UndoClear()
{
    var docs = Application.DocumentManager;
    var doc = docs.MdiActiveDocument;
    variable = doc.Editor;
    try
    {
        wait docs.ExecuteInCommandContextAsync(
          async(obj)=>{awased.CommandAsync("Undo", "C", "N", "UNDO", "A");},
          Null
        );
    }
    catch{}
}

IJCAD does not implement ExecuteInCommandContextAsync, so use COM and LISP to invoke UNDO commands.

 CommandMethod("TESTCMD", CommandFlags.Session)
public void TestCommand(){
    varacadDoc=(dynamic)Application.AcadApplication).ActiveDocument;
    acadDoc.SendCommand("(command\"UNDO\"\"C\"\"N\"\"UNDO\"\"A\"")\n";
}

However, this method leaves (command "UNDO" "C" "N" "UNDO" "A") and nil on the command line.


2022-09-30 19:55

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.