打开下一个图形
我正在寻找一个命令,将打开文件夹中的下一个图形。例子:
您有文件A.dwg,只需键入“打开下一个”即可打开B.dwg
你有文件C.dwg,你只需键入“打开下一个”,它会打开D.dwg,等等。
提前感谢 您可以使用以下命令读取文件名:(vl filename base(getvar'dwgname))
然后,可以使用if filename=a.dwg创建if/else例程,然后打开B.dwg。
具有
(setq str1 (strcat (vl-filename-base (getvar 'dwgname))))
(setq str4(substr str1 5 )
您可以从文件名中删除某些字母。
然后将其与以下材料一起成型:
(setq str8 (strcat "blablabla" str4 "-" str6))
我不是很好(像这里的一些人),我可以在5分钟内完成代码
但我认为学习autolisp是一个很好的lisp,因为它并不复杂。(所以你自己试试!) 谢谢你的重播,我对lisp一点也不擅长,但我会尝试一下,我可以编辑它们来做我需要的事情,这是我能做的。 可能是这样(未经测试):
(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文件,以便在打开新图形时清除列表。 使用黑板名称空间Irne的好主意,很好的编码 我可以这样做:
(defunc:打开下一个(();;©Lee Mac 2010(if(cond((((getvarDWGNAMEsetqf(vl sortvl directory filesgetvar“DWGPREFIX[”*.dwg“1 在尝试使用您的代码irned时,我遇到了以下错误:
; 错误:自动化错误。绘图正忙。 哇,李-麦克,看起来效果不错 所以如果我改变一下:
(setq f(vl排序(vl目录文件(getvar“DWGPREFIX)”*.dwg“1)”
到
(setq f(vl排序(vl目录文件(getvar“DWGPREFIX)”*.dwg“1)>)
它将打开之前的绘图,我尝试了一下,它成功了。 这不是编码这是黑魔法
页:
[1]
2