+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Super Member Bill Tillman's Avatar
    Using
    AutoCAD 2014
    Join Date
    Oct 2008
    Location
    Miami, FL
    Posts
    1,068

    Default To Exit or Not to Exit

    Registered forum members do not see this ad.

    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.

  2. #2
    Forum Deity BlackBox's Avatar
    Computer Details
    BlackBox's Computer Details
    Operating System:
    Windows 8.1 Professional, Server 2012 R2 Datacenter
    Computer:
    Dell Precision T3600
    CPU:
    Hex-Core Intel Xeon 3.2Ghz
    RAM:
    32GB
    Graphics:
    3GB NVIDIA Quadro K4000
    Primary Storage:
    256GB SSD
    Secondary Storage:
    1TB Western Digital VelociRaptor 10K RPM
    Monitor:
    Dual 24" Dell Ultrasharp Widescreen Monitors
    Using
    Civil 3D 2015
    Join Date
    Nov 2009
    Posts
    4,753

    Default

    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
                );
    //
    "Potential has a shelf life." - Margaret Atwood
    AutoCAD® 2014, and Civil 3D® 2014 Certified Professional | Autodesk® Authorized Developer
    Autodesk Exchange Apps ~ Autoloader ~ AutoCAD Security

Similar Threads

  1. Exit from (while...
    By GP_ in forum AutoLISP, Visual LISP & DCL
    Replies: 7
    Last Post: 23rd Jul 2012, 11:43 am
  2. Replies: 0
    Last Post: 9th Aug 2011, 04:40 am
  3. Retaining settings upon exit
    By seila in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 6th Oct 2010, 05:30 pm
  4. On Exit Click
    By Robert J in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 13th Oct 2007, 08:28 pm
  5. Exit handling...
    By pefi in forum AutoLISP, Visual LISP & DCL
    Replies: 13
    Last Post: 2nd Aug 2006, 11:06 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts