可能是这样(未经测试):
- (vl-load-com)
- (defun c:Open-Next (/ path files-list files DocCol item n)
- (setq path (getvar "DWGPREFIX") ;Get the current DWG's path
- DocCol (vla-get-Documents (vlax-get-acad-object)) ;Get the ActiveX collection of open DWG's
- n 0
- )
- (if (and (setq files-list (vl-bb-ref 'Open-Next-List)) ;Check if Open-Next has been used before
- (setq files (assoc path files-list)) ;If so has it been used on this folder?
- )
- ;; Then
- (setq files (cdr files)) ;Remove the path prefix of the list
- ;; Else
- (setq files (vl-directory-files path "*.DWG" 1)) ;Get the files in this directory
- )
- (while (and (< n (length files))
- (or (not (eq (strcase (getvar "DWGNAME")) (strcase (nth n files)))) ;Check that not the current DWG
- (and (setq item (vl-catch-all-apply 'vla-Item (list DocCol (nth n files))))
- ;Check if one of the other opened
- (not (vl-catch-all-error-p item)) ;Check if error
- )
- )
- )
- (if (and item (not (vl-catch-all-error-p item))) ;If another DWG
- (vla-Close item)
- )
- (setq n (1+ n) item nil) ;Increment counter
- )
- (if (setq item (assoc path files-list)) ;If already in list
- ;; Then
- (setq files-list (subst (cons path files) item files-list)) ;Replace with the new set of files
- ;; Else
- (setq files-list (cons (cons path files) files-list)) ;Add the current folder & files list
- )
- (vl-bb-set 'Open-Next-List files-list)
- (if (< n (length files))
- (vl-cmdf "_.OPEN" (strcat """ path (nth n files) """))
- )
- (princ)
- )
- (defun Open-Next-Cleanup (/ files-list files path DocCol)
- (setq path (getvar "DWGPREFIX") ;Get the current DWG's path
- DocCol (vla-get-Documents (vlax-get-acad-object)) ;Get the ActiveX collection of open DWG's
- n 0
- )
- (if (and (setq files-list (vl-bb-ref 'Open-Next-List))
- (setq files (assoc path files-list))
- )
- (while (or (not (eq (strcase (getvar "DWGNAME")) (strcase (car files)))) ;Check that not the current DWG
- (and (setq item (vl-catch-all-apply 'vla-Item (list DocCol (car files))))
- ;Check if one of the other opened
- (not (vl-catch-all-error-p item)) ;Check if error
- )
- )
- (if (and item (not (vl-catch-all-error-p item))) ;If another DWG
- (vla-Close item)
- )
- (setq files (cdr files) item nil)
- )
- )
- (if (setq item (assoc path files-list)) ;If already in list
- ;; Then
- (setq files-list (subst (cons path files) item files-list)) ;Replace with the new set of files
- ;; Else
- (setq files-list (cons (cons path files) files-list)) ;Add the current folder & files list
- )
- (vl-bb-set 'Open-Next-List files-list)
- )
- (if (and s::startup (= (type s::startup) 'LIST))
- (setq s::startup (append s::startup (list (Open-Next-Cleanup))))
- (defun-q s::startup
- ()
- (Open-Next-Cleanup)
- )
- )
需要复制到您的ACADDOC。LSP文件,以便在打开新图形时清除列表。 |