TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Adesu on February 06, 2007, 09:49:54 PM

Title: How to close one session drawing
Post by: Adesu on February 06, 2007, 09:49:54 PM
Hi Alls,
I just attempt a code to open one session,and then close again,but this code still got trouble,what am I doing wrong?
Code: [Select]
(defun c:test (/ fn vgad vgao vgd)
  (vl-load-com)
  (setq fn "D:/YBI/Drawing/Lat/Test-1.dwg")   
  (setq vgao (vlax-get-acad-object))
  (setq vgad (vla-get-activedocument vgao))
  (setq vgd (vla-get-documents vgao))
  (if
    (= 0 (getvar "SDI"))
    (vla-activate (vla-open vgd fn))                               ; if sdi = 0
    (vla-sendcommand vgad (strcat "(command \"_open\")\n" fn "\n")); if sdi = 1
    )                                                                    ; if 
  (command "_copyclip" "all" "")
  ;(vla-close vgad)
  (vla-sendcommand vgad (strcat "(command \"_quit\")\n" fn "\n"))
  (princ)
  )
Title: Re: How to close one session drawing
Post by: Keith™ on February 07, 2007, 01:06:59 AM
for one thing you do not need to pass the name of the drawing to the quit command
Title: Re: How to close one session drawing
Post by: Adesu on February 08, 2007, 12:51:58 AM
Hi Keith™
This code still alls session close,not yet as I want,I mean open "Test-1.dwg" then close again "Test-1.dwg".

Code: [Select]
(defun c:ocdv (/ fn vgad vgao vgd)
  (vl-load-com)
  (setq fn "D:/YBI/Drawing/Lat/Test-1.dwg")   
  (setq vgao (vlax-get-acad-object))
  (setq vgad (vla-get-activedocument vgao))
  (setq vgd (vla-get-documents vgao))
  (if
    (= 0 (getvar "SDI"))
    (vla-activate (vla-open vgd fn))                               ; if sdi = 0
    (vla-sendcommand vgad (strcat "(command \"_open\")\n" fn "\n")); if sdi = 1
    )                                                                    ; if 
  ;(command "_copyclip" "all" "")
  (vla-sendcommand vgad (strcat "(command \"_quit\")\n"))
  (princ)
  )

for one thing you do not need to pass the name of the drawing to the quit command
Title: Re: How to close one session drawing
Post by: Keith™ on February 08, 2007, 09:01:02 AM
The quit command closes AutoCAD, you will need to set the drawing as the current document, then pass the close command to the drawing