I'm using the following to grab an existing instance of AutoCAD, if it's there, if not open one, and then open an existing drawing, then load and run a LISP program. The trouble with this is that I allow the LISP program to close the drawing and then VB.NET closes AutoCAD. But it closes it before the LISP program is finished. Is there some way to force the Quit command to wait until the LISP program is completed. I've tried using a sleep but that doesn't appear to work. The LISP program takes about 5-10 seconds to complete it's work.
Code:Try IfProcess.GetProcessesByName("acad").Length > 0 Then vAcadApp = GetObject(, "AutoCAD.Application.19") Else vAcadApp = NewAcadApplication EndIf Dim TemplateName AsString = "My_Automated_Drawing.dwg" vAcadApp.Visible = True vAcadApp.WindowState = AcWindowState.acMax vAcadDoc = vAcadApp.Documents.Open("\\my_server_path\" & TemplateName, True) vAcadDoc.SendCommand("(load ""//my_server_path/LISP/" _ & lisptype & ".lsp"" ""The load failed"") " & lsiptype & Chr(13)) Catch ex AsException Finally 'vAcadApp.Quit() vAcadApp = Nothing vAcadDoc = Nothing EndTry
It's deja vu, all over again.
Registered forum members do not see this ad.
Rather than invoking the Quit() Method, wouldn't again invoking SendStringToExecute() run the QUIT Command synchronously ?
Code:// C# vAcadDoc.SendStringToExecute( "Quit\n", false, false, true ); //