找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 962|回复: 6

[求助] [求助]:如何用lisp实现closeall,但是不保存哦?

[复制链接]
发表于 2006-3-8 12:15:46 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
如何用lisp实现closeall但是不保存?
又如何实现closeall,保存?
谢谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
发表于 2006-3-8 13:28:30 | 显示全部楼层
[php](defun c:closeall-no (/ item cur)
  (vlax-for item (vla-get-documents (vlax-get-acad-object))
    (if        (= (vla-get-active item) :vlax-false)
      (vla-close item :vlax-false)
    )
  )
  (command "CLOSE" "y" "")
)

(defun c:closeall-yes (/ item cur)
  (vlax-for item (vla-get-documents (vlax-get-acad-object))
    (if        (= (vla-get-active item) :vlax-false)
      (vla-close item :vlax-true)
    )
  )
  (command "qsave" "" "CLOSE")
)

[/php]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2006-3-8 16:00:31 | 显示全部楼层
呵呵,说来真是奇怪,楼上大哥的程序在CAD2006中过得去,但是在CAD2005中却不行?
谢谢了!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2006-3-9 11:55:53 | 显示全部楼层
麻烦2楼再改进一下吧
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2006-3-9 13:07:32 | 显示全部楼层
看来2006的vl可以跨文档了?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2006-3-9 13:10:08 | 显示全部楼层
还没有找到解决的办法
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

已领礼包: 8157个

财富等级: 富甲天下

发表于 2006-3-9 13:59:18 | 显示全部楼层
;;; 全不保存
;;; I believe Frank Whaley posted this originally.
(defun ax:CloseAll ( / item cur)
    (vlax-for item (vla-get-documents (vlax-get-acad-object))
      (if (= (vla-get-active item) :vlax-false)
        (vla-close item :vlax-false)
        (setq cur item)
      )
    )
    ;(vla-sendcommand cur "_.CLOSE ")      ;; 停等 ....
    ;(command "._VBASTMT" "ThisDrawing.Close True")
    (command "._VBASTMT" "ThisDrawing.Close False")
)

========================================================

Ref: info

From:  LEndres - view profile
Date:  Mon, May 1 2000 12:00 am  
Email:   LEndres <lend...@sesnet.com>
Groups:   autodesk.autocad.customization

I tried to do something like this myself, but there are several problems with it.
First, it doesn't check to see if a command is running in the drawing.  If there is a command running then the vla-close will give an error.  Is there a way to test to see if a command is running and cancel it (can you use (getvar "cmdactive") inside of the vla-for loop and return the cmdactive from the correct document)?
Second, there is a problem when a new drawing has been started but not saved.  I have used the vla-get-fullname property to test for this (as Frank suggested in an earlier post), but I would like to ask the user if they want to save the drawing, and if so, allow for a save as.  I haven't been able to get this to work either.

Third is that the (vla-sendcommand cur "_.CLOSE") seems to be sending the close command to the command line, but not running it.

I have pasted my very pathetic code below.  Perhaps someone can fix this hack job.  Obviously my knowledge of visual lisp is very low!  Thanks for the help.


(defun CLOSE-ALL-OPEN-FILES (/ ACADOBJ ACTDOC ITEM)
    (vl-load-com)
    (setq ACADOBJ (vlax-get-acad-object))
    (vlax-for ITEM (vla-get-documents ACADOBJ)
        (if (not (= ITEM
                    (vla-get-activedocument ACADOBJ)
                 ) ;_ End =
            ) ;_ End not
            (if (and (= (vla-get-fullname ITEM) "")
                     (= (vla-get-saved ITEM) :vlax-false)
                ) ;_ End and
                (CLOSE-UNSAVED-FILE ITEM)
                (progn

                    ;Cancel command if running

                    (vla-close ITEM)
                ) ;_ End progn
            ) ;_ End if
        ) ;_ End if
    ) ;_ End vlax-for
    (setq ACTDOC (vla-get-activedocument ACADOBJ))
    (if (and (= (vla-get-fullname ACTDOC) "")
             (= (vla-get-saved ACTDOC) :vlax-false)
        ) ;_ End and
        (CLOSE-UNSAVED-FILE ACTDOC)
        (progn

            ;Cancel command if running

            (command "_.close")
            (while (= (logand (getvar "CMDACTIVE") 1) 1)
                (command "y")
            ) ;_ End while
        ) ;_ End progn
    ) ;_ End if
) ;_ End defun


(defun CLOSE-UNSAVED-FILE (ITEM / OPTION)
    (vla-put-activedocument (vlax-get-acad-object) ITEM)
    (initget "Yes No")
    (setq OPTION (getkword "\nSave drawing? [Yes/No] <Yes>: "))
    (if (or (= OPTION "") (= OPTION "Yes"))
        (progn
            (initdia)

            ;Cancel command if running

            (command
                "_.saveas"
                (while
                    (= (logand (getvar "CMDACTIVE") 1)
                       1
                    ) ;_ End =
                       (command
                           PAUSE
                       ) ;_ End command
                ) ;_ End while
            ) ;_ End command
        ) ;_ End progn
    ) ;_ End if
) ;_ End defun
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-29 04:03 , Processed in 0.328258 second(s), 44 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表