如果同时打开几个DWG文件,如何将除当前文件外的其余文件全部关闭?谢谢!
如题……请求帮助……谢谢!很好用 终于找到了 好久的帖子了哈 老帖子,支持一下 一起等待高手出现! 本帖最后由 Andyhon 于 2013-9-10 07:45 编辑
;|
alanjt 14th Oct 2010, 08:41 pm
I use this to close all but the active drawing...
|;
(defun c:CABA (/)
;; Close all but active drawing (with option to save inactive)
;; Express Tool subroutine "ACET-UI-Message" required
;; Alan J. Thompson, 06.09.10
((lambda (save)
(vlax-for x (vla-get-documents
(cond (*Acad*)
((setq *Acad* (vlax-get-acad-object)))
)
)
(or (eq :vlax-true (vla-get-active x))
(vl-catch-all-apply (function vla-close) (list x save))
)
)
)
(if (eq 6
(acet-ui-message
"Save drawings before closing?"
"Close All But Active Drawing"
52
)
)
:vlax-true
:vlax-false
)
)
(princ)
)
More info:
http://www.afralisp.net/archive/Tips/code42.htm
http://forums.autodesk.com/t5/Vi ... no-save/m-p/2662606 (defun c:tt()
(setq docs (vla-get-documents (vlax-get-acad-object)))
(setq cdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for doc docs
(if (not (equal cdoc doc))
(progn
(vla-Close doc :vlax-true )
)
)
)
) 本帖最后由 xhq1954425 于 2013-9-10 19:06 编辑
在金秋十月来临之际..仅以此表达谢意
Gu_xl 发表于 2013-9-10 14:55 static/image/common/back.gif
你的程序简单好使,我想通过选用(getvar 'DWGTITLED),仅关闭所有没存过盘的新建文件,应该怎样写?谢谢! Gu_xl 发表于 2013-9-10 14:55 static/image/common/back.gif
(defun c:gdn()
(setq docs (vla-get-documents (vlax-get-acad-object)))
(setq cdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for doc docs
(if (not (equal cdoc doc))
(progn
(vla-Close doc :vlax-true )
))))
(command"quit" "y" "n")(princ))
终于不用一直按着 N 了!实在太感谢G版。可不可以加个功能,把电脑也关掉呢?晚上下班时就感觉爽多了........ xhq1954425 发表于 2013-9-11 07:51 static/image/common/back.gif
你的程序简单好使,我想通过选用(getvar 'DWGTITLED),仅关闭所有没存过盘的新建文件,应该怎样写?谢谢! ...
给你两个思路参考
思路一
,在G版的基础上,增加下面两行:
(vla-activate doc)
(if (= (getvar 'DWGTITLED) 0) 记录文件名
;即把全部文档设为一次当前文档,如果当前文档是新文件则记录,然后关闭有记录的文件;
思路二:
getvar 'DWGTITLED 可与 (Vlax-Get doc 'FullName) 作同样的判断
getvar 'DWGTITLED 为0 时,(Vlax-Get doc 'FullName)为空字符串
getvar 'DWGTITLED 为1 时,(Vlax-Get doc 'FullName)为全路径名字符串;
因此,可以用下面的:
(defun c:tt()
(setq docs (vla-get-documents (vlax-get-acad-object)))
(setq cdoc (vla-get-ActiveDocument (vlax-get-acad-object)))
(vlax-for doc docs
(if (not (equal cdoc doc))
(if (= (Vlax-Get doc 'FullName) "")
(progn
(vla-Close doc :vlax-false )
)
)
)
)
)
669423907 发表于 2013-9-11 09:42 static/image/common/back.gif
(defun c:gdn()
(setq docs (vla-get-documents (vlax-get-acad-object)))
(setq cdoc (vla-get-Acti ...
在退出cad之前,增加以下的命令,即可关机了。
(command "shell" "shutdown -f -s -t 10") ;10秒后关机
页:
[1]
2