.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Cancelling any running commands

4 REPLIES 4
Reply
Message 1 of 5
Paulio
2105 Views, 4 Replies

Cancelling any running commands

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

 

 

4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Paulio

You can check the Document.CommandInProgress()

 

Here is using COM

                Document doc = Application.DocumentManager.MdiActiveDocument;
                AcadDocument acadDoc = (AcadDocument)doc.AcadDocument;
                acadDoc.SendCommand("\x03\x03");
Message 3 of 5
Paulio
in reply to: Anonymous

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

Message 4 of 5
cadMeUp
in reply to: Paulio

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

Message 5 of 5
Paulio
in reply to: cadMeUp

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost