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
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.