我想利用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)
- )
|