Lisp To AUTOMATICALLY Save And Close All Opened Files
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
MACRO
The below MACRO, I use it when I have lots of drawings opened to change some items in them.
Say I have 5 or 20 sheets opened to change something on each of the sheets.
I added it to my CUIX and added a button for it.
1. Open 5 or 20 or more sheets
2. I would use the CTRL/TAB keys to cycle
through the individual sheets for the edits.
3. ^C^C_purge;all;*;n;zoom;e;qsave;CLOSE;
When done with all the sheets, I would use
this MACRO (button on my personal toolbar),
to close the opened sheets, one by one.
-------------------------------------------------------------------------------
LISP
CloseAllButActive.lsp
This will close all opened files, without zooming and saving, just close all opened files except leave the current file opened. If I have 20 files opened, and am on sheet 5, with this LISP, every other opened file will be closed while sheet 5 (current) will remain opened.
(defun doc:CloseAllButActive (TrueOrFalse / cnt)
(setq cnt 0)
(vlax-for Item (vla-get-Documents (vlax-get-acad-object))
(if (= (vla-get-Active Item) :vlax-False)
(progn
(vla-close Item TrueOrFalse)
(setq cnt (1+ cnt))
)
)
)
cnt
)
(defun c:cns ( / cnt) ;CLOSES ALL NO SAVE BUT CURRENT ACTIVE
(setq cnt (doc:CloseAllButActive :vlax-False))
(if (> cnt 0)
(princ (strcat "\n(" (itoa cnt) ") document" (if (> cnt 1) "s" "") "
closed without saving."))
(princ "\nNo documents to close.")
)
(princ)
)
-------------------------------------------------------------------------------
My ideal goal would be to kinda combine both the MACRO and the LISP to achieve the following.
With say, 20 files opened, edit each file by cycling with the CTRL/TAB, when done with all edits, apply one LISP or MACRO, to do what the above MACRO does, but also automatically save and close the files one by one. That is:
_purge;all;*;n;zoom;e;qsave;CLOSE; then go to the next opened file and do the same all over again.
I thought I had the LISP to do this, but cannot find it. Seen lots of close functions but not exactly what I am looking for. I would really appreciate if anyone would help me. I hope I am clear enough with my needs, with my English here.
Cheers