AutoCad Command Rejected “Undo” when using Application.Invoke()

前端 未结 1 1344
既然无缘
既然无缘 2021-01-26 12:30

I am using Application.Invoke() to invoke AutoLisp commands in AutoCad synchronously. Most of my commands work fine, but there are several that come up with the error



        
1条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-26 13:14

    I think it's because c:wd_insym2 is calling these commands. It fails because your own command is already active. You need to call this command asynchronously with SendStringToExecute or may be Editor.Command/CommandAsync. If you need to additional processing after the command has executed, add an handler to the CommandEnded event:

    doc.CommandEnded += doc_CommandEnded;
    doc.SendStringToExecute("(c:wd_insym2 "C:/ace_blocks/HT00_001.dwg" '(150 230) nil nil)", false, false, false);
    
    [..]
    
    void doc_CommandEnded(object sender, CommandEventArgs args)
    {
        // Do what you need to do
    
        // Remove the handler
        doc.CommandEnded -= doc_CommandEnded;
    }
    

    You should also add an handler to the CommandFailed event in case of failure of the c:wd_insym2 command.

    0 讨论(0)
提交回复
热议问题