AfraLisp Blog

The AutoLisp/Visual Lisp/VBA Resource Website

AfraLisp Blog

Home Newsletter Utter Rubbish Coding Tips AutoCAD Tips Contact Downloads WAUN

Peter Jamtgaard very kindly gave me permission to publish this.

Have you ever had a gazillion drawings open in mdi mode and just wanted to shut down a bunch of them, but not all of them quickly.

This program displays a dialog box with all of the open acad documents listed. You can multiple select the ones you want to close and pick o.k. It has some kinda cool stuff in it for everyone.

//DCL CODING STARTS HERE
dddwgs : dialog {
label="Select Documents to close";
:list_box { key = "dwgs";
height = 20;
width = 30;
multiple_select = true;
allow_accept = true;
}
ok_only;
}
//DCL CODING ENDS HERE

Save this as "CLOSE_DWG.DCL"

;AUTOLISP CODING STARTS HERE
(defun C:CLOSE_DWG (/ ACADOBJ DOCOBJ DOCSOBJ FULL NAME PATH)
(vl-load-com)
(get_docs_list)
(ddcloser)
(if DWGLST
(progn
(setq CNT (- (length DWGLST) 1))
(repeat (length DWGLST)
(setq DOCOBJ (vlax-invoke-method DOCSOBJ "item" (nth CNT DWGLST))
CNT (1- CNT)
PATH (vlax-get-property DOCOBJ "path")
NAME (vlax-get-property DOCOBJ "name")
FULL (strcat PATH "\\" NAME)
)
(if (= (vlax-get-property DOCOBJ "active") :vlax-false)
(vla-close DOCOBJ :vlax-true FULL)
(princ (strcat "\nDrawing " FULL " is still active: "))
)
(vlax-release-object DOCOBJ)
)
(vlax-release-object DOCSOBJ)
(vlax-release-object ACADOBJ)
)
)
(princ)
)

(defun GET_DOCS_LIST ()
(setq ACADOBJ (vlax-get-acad-object)
DOCSOBJ (vlax-get-property acadobj "Documents")
DOCSLIST nil
)
(vlax-for FOR-ITEM DOCSOBJ
(setq DOCSLIST (cons
(strcat (vlax-get-property FOR-ITEM "Path") "\\"
(vlax-get-property FOR-ITEM "Name")
)
DOCSLIST
)
)
)
(setq DOCSLIST (reverse DOCSLIST))
(princ)
)

(defun DDCLOSER (/ DWGS DWGNUM IDD )
(setq IDD (load_dialog "close_dwg.dcl"))
(new_dialog "dddwgs" IDD)
(start_list "dwgs")
(mapcar 'add_list DOCSLIST)
(end_list)
(action_tile "dwgs" "(setq DWGLST (read (strcat \"(\" $value \")\")))")
(setq start (start_dialog))
(setq ddone (done_dialog))
)
(princ "\nC:CLOSE_DWG")
(princ)
;AUTOLISP CODING ENDS HERE

Save this as "CLOSE_DWG.LSP"

The AutoLisp/Visual Lisp/VBA Resource Website

Copyright 1999-Perpetuity by AfraLisp

All rights reserved.
Information in this document is subject to change without notice.
Site created and maintained by Kenny Ramage

The AutoLisp/Visual Lisp/VBA Resource Website