Cancelling any running commands

Cancelling any running commands

Paulio
Advocate Advocate
2,316 Views
4 Replies
Message 1 of 5

Cancelling any running commands

Paulio
Advocate
Advocate

I'm trying to figure out essentially how to send a few escape key presses to AutoCAD when I run a procedure in my code to make sure that nothing else is running.

 

It's ok if I run my command from a palette as I just preceed the command string with ^c^c which is fine. The code I'm running gets kicked off by a button press on a modeless form though so in theory the user could be halfway through doing anything in AutoCAD when they click my button.

 

I thought about using acedPostCommand as suggested in Kean's blog here:

http://through-the-interface.typepad.com/through_the_interface/2006/08/cancelling_an_a.html

 

The problem with that is that there are (or seem to be) different entry points for 32 and 64 bit so I don't know how to declare the function so it will work. I need my app to work on either.

 

So, I thought I'd try Tony T's commandline thing; the problem with that is that I can't seem to figure out how to pass it what I want. I need to pass it chr(27) but can't get it to work. Am I just being thick? (don't answer that)

 

This must have come up before but I can't find anything or anyone who's done it.

 

Thanks in advance

 

Paul

 

 

2,317 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

You can check the Document.CommandInProgress()

 

Here is using COM

                Document doc = Application.DocumentManager.MdiActiveDocument;
                AcadDocument acadDoc = (AcadDocument)doc.AcadDocument;
                acadDoc.SendCommand("\x03\x03");
0 Likes
Message 3 of 5

Paulio
Advocate
Advocate

Thanks for that, but is there any way to do it without COM?

0 Likes
Message 4 of 5

cadMeUp
Collaborator
Collaborator

You can trying something like the following:

 

Autodesk.AutoCAD.Internal.PreviousInput.CommandLineMonitorServices comLineMonServ =
 Autodesk.AutoCAD.Internal.PreviousInput.CommandLineMonitorServices.Instance();
foreach (Document doc in AcadApp.DocumentManager)
{
 if (doc == AcadApp.DocumentManager.MdiActiveDocument)
  continue;

 Autodesk.AutoCAD.Internal.PreviousInput.CommandLineMonitor comMon = comLineMonServ.GetCommandLineMonitor(doc);
 if(comMon.CurrentCommandName.Length != 0)
  doc.SendStringToExecute("\x03\x03", false, true, false);
}

 

Not sure if it will work on 64bit?, I'm on 32

0 Likes
Message 5 of 5

Paulio
Advocate
Advocate

Thanks cadMeUp but I've already had a go at the sendstringtoexecute too. (sorry should've mentioned that)

 

The button on my form asks the user to select a block or blocks in the drawing but if I do sendstringtoexecute it seems to get there too late and actually cancels my getselection instead of cancelling whatever's running then doing my getselection.

 

I need something that's going to run synchronously.

 

Thanks again for your effort though.

0 Likes