TheSwamp

Code Red => .NET => Topic started by: leo_li on March 14, 2006, 09:10:13 PM

Title: stop the lisp program in c#.net
Post by: leo_li on March 14, 2006, 09:10:13 PM
I "SendStringToExecute" a lisp program in c#.net. Now send the second lisp program in c#.net. Before I the second lisp want to stop the first lisp program just like press Esc key. Is it possible? Thanks a lot
Title: Re: stop the lisp program in c#.net
Post by: Kerry on March 14, 2006, 09:29:05 PM
I haven't used SendStringToExecute() mainly because of it's asynchronous nature.
Title: Re: stop the lisp program in c#.net
Post by: leo_li on March 15, 2006, 02:17:13 AM
 You are right. It is a really big program. But I create a Dock Palette with C#.net. I add some buttons on it. I can load different lisp program by click each button. When I click one button, the lisp program will be running in the command. If you click another button at this time, the new lisp program won't be loaded because of the first lisp program is not finished. So when I click the second buuton, I want to stop the first lisp program before I load the second lisp program. Is it poosible in C#.net?
Title: Re: stop the lisp program in c#.net
Post by: Kerry on March 15, 2006, 03:05:09 AM
I think I understand you.

I assume the net assembly ONLY creates the Palette with the buttons, everything after that would follow the "normal" acad rules, so I cant think of a way to consistantly do what you want. Have you tried adding ^C^C to the command string in the Palette command.
Title: Re: stop the lisp program in c#.net
Post by: leo_li on March 25, 2006, 07:06:33 AM
^c^c doesn't work. I see some command seems useful.
AcadApp.DocumentManager.MdiActiveDocument.CommandCancelled...
AcadApp.DocumentManager.MdiActiveDocument.LispCancelled...
But I don't know how to use it. Could anyone tell me, are those command can be used in this case?
Title: Re: stop the lisp program in c#.net
Post by: Alexander Rivilis on March 25, 2006, 11:00:20 AM
^c^c doesn't work. I see some command seems useful.
AcadApp.DocumentManager.MdiActiveDocument.CommandCancelled...
AcadApp.DocumentManager.MdiActiveDocument.LispCancelled...
But I don't know how to use it. Could anyone tell me, are those command can be used in this case?
You can not call theese functions - it is a reactors function which called by AutoCAD if command canceled or lisp-function  canceled.
IMHO, thay can not help you. :(

I've not tested but you can try call finction acedCommandCancelled():

Code: [Select]
[System.Security.SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl)]
extern static public acedCommandCancelled();

Another way is using Autodesk.AutoCAD.Interop.IAcadDocument.SendCommand(System.String Command);
This call is synchronous!
You need add to your project reference to AutoCAD COM library.