编了个简单的程序,将就的用
(defun ts_err() (setvar "cmdecho" 0) (setvar "filedia" 0) (setq olderr *error* )
(defun *error*(msg) (princ "\n程序中断,未清除任何“命名图层过滤器”") (close *dxf文件_old) (close *dxf文件_new) (setvar "filedia" 1) (setvar "cmdecho" 1) (setq *error* olderr) (princ) )
(princ) )
(defun c:pulf() (princ "\n本程序将完全清理文件内的“命名图层过滤器”。") (princ "\n若文件内并无“命名图层过滤器”,运行本程序可能导致死循环.") (princ "\n程序长时间无反应,请按“ESC键”退出,并检查文件内是否含有“命名图层过滤器”.") (princ "\n若文件内确实含有“命名图层过滤器”,请再次运行本程序,并耐心等待") (ts_err) (setq *dwgname (getvar "DWGNAME")) (setq *dwgname (strcat (substr *dwgname 1 (- (strlen *dwgname) 4)) ".dwg" )) (setq *dxfname (strcat (substr *dwgname 1 (- (strlen *dwgname) 4)) ".dxf" )) (setq *scrname (strcat (substr *dwgname 1 (- (strlen *dwgname) 4)) ".scr" )) (setq *path (getvar "DWGPREFIX")) (setq *alldxf (strcat *path *dxfname)) (setq *alldwg (strcat *path *dwgname)) (setq *allscr (strcat *path *scrname))
(princ "\n正在清理图层过滤器,请稍后....") (princ)
(setq *dxf文件_old (open *alldxf "w")) (close *dxf文件_old) (command "saveas" "DXF" "V" "2000" "16" *alldxf "y") (command "saveas" "2000" *alldwg "y") (清理层过滤表) (关再开) (princ) )
(defun 清理层过滤表() (setq *dxf文件_old (open *alldxf "r")) (setq *dxf文件_new (open (strcat (substr *alldxf 1 (- (strlen *alldxf) 4)) "new.dxf" ) "w") ) (setq loop_1 T) (while loop_1 (setq a (read-line *dxf文件_old)) (cond ((null a)(setq loop_1 nil) ) ((= a "AcDbDictionary") (write-line a *dxf文件_new) (progn (setq loop_2 T) (while loop_2 (setq a1 (read-line *dxf文件_old)) (setq a2 (read-line *dxf文件_old)) (setq a3 (read-line *dxf文件_old)) (setq a4 (read-line *dxf文件_old)) (write-line a1 *dxf文件_new) (write-line a2 *dxf文件_new) (write-line a3 *dxf文件_new) (write-line a4 *dxf文件_new) (if (and (= a1 "280") (= a2 " 1") (= a3 "281") (= a4 " 1") ) (progn (setq loop_3 T) (while loop_3 (setq a1 (read-line *dxf文件_old)) (setq a2 (read-line *dxf文件_old)) (if (and (= a1 " 0")(= a2 "DICTIONARY")) (progn (write-line a1 *dxf文件_new) (write-line a2 *dxf文件_new) (setq loop_3 nil) (setq loop_2 nil) ) ) ) ) (setq loop_2 nil) ) ) ) ) ((/= a "AcDbDictionary") (write-line a *dxf文件_new) ) ) ) (close *dxf文件_old) (close *dxf文件_new) (princ "ok") (princ "\n重新打开文件")(princ) (princ) )
(defun 关再开() (setq *scrfile (open *allscr "w")) (write-line "close" *scrfile) (write-line "open" *scrfile) (write-line (strcat (substr *alldxf 1 (- (strlen *alldxf) 4)) "new.dxf" ) *scrfile) (write-line "saveas" *scrfile) (write-line "2000" *scrfile) (write-line *alldwg *scrfile) (write-line "Y" *scrfile) (write-line "filedia" *scrfile) (write-line "1" *scrfile) (write-line "cmdecho" *scrfile) (write-line "1" *scrfile) (close *scrfile) (command "script" *allscr) ) |