TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started 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?
(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)
)
-
for one thing you do not need to pass the name of the drawing to the quit command
-
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".
(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
-
The quit command closes AutoCAD, you will need to set the drawing as the current document, then pass the close command to the drawing