Author Topic: How to close one session drawing  (Read 2458 times)

0 Members and 1 Guest are viewing this topic.

Adesu

  • Guest
How to close one session drawing
« 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)
  )

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: How to close one session drawing
« Reply #1 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Adesu

  • Guest
Re: How to close one session drawing
« Reply #2 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

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: How to close one session drawing
« Reply #3 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
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie