编LISP求助,程序不能按设计意图运行!!!!!
我想利用LISP 对当前打开的文件,其所在文件夹的所有DWG文件进行批量处理,可程序运行后,总对当前打开的文件起作用,不能对批量打开的DWG文件进行处理,,,,请高手帮忙!!!!(defun C:bclf ()(vl-load-com)
(setq HOLDECHO (getvar "cmdecho"))
(setvar "cmdecho" 0)
(setq HOLDLSP (getvar "ACADLSPASDOC"))
(setvar "acadlspasdoc" 0)
(if (= (getvar "DWGTITLED") 1)
(progn
(setq path (getvar "DWGPREFIX"))
(setq
DWG_LIST (acad_strlsort (vl-directory-files path "*.dwg" 1))
)
(setq list_number (vl-list-length dwg_list))
(setq index 0
nm 0
)
(repeat list_number
(setq dwgfile (nth index DWG_LIST))
(vla-open (vla-get-documents (vlax-get-acad-object))
(strcat path dwgfile)
)
(vl-Catch-All-Apply
'(lambda ()
(vla-Remove
(vla-GetExtensionDictionary
(vla-Get-Layers
(vla-Get-ActiveDocument (vlax-Get-Acad-Object))
)
)
"ACAD_LAYERFILTERS"
)
)
)
(command "purge" "a" "*" "n")
(setq index (1+ index))
(setq nm (1+ nm))
(command "qsave")
)
)
(alert "You Must Open An Exited Dwg-file With READ-ONLY First!")
)
(prompt (strcat "Batch operate " (itoa nm) " files!"))
(setvar "acadlspasdoc" HOLDLSP)
(setvar "cmdecho" HOLDECHO)
(princ)
)
lsp, 每个图形打开时都会重新初始化 lsp 环境的, 所以想通过 lsp 来进行批处理是不可以的. 可以通过 ActiveX, scr 脚本文件等来实现
页:
[1]