也许是这样?
- (defun c:test ( / *error* a b c d e f )
- ;; © Lee Mac 2011
- (defun *error* ( msg )
- (if c (setvar 'CMDECHO c))
- (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
- (princ (strcat "\n** Error: " msg " **")))
- (princ)
- )
-
- (setq c (getvar 'CMDECHO))
- (setvar 'CMDECHO 0)
- (while (setq b (tblnext "BLOCK" (null b)))
- (if
- (= 4 (logand 4 (cdr (assoc 70 b))))
- (setq a (cons "," (cons (cdr (assoc 2 b)) a)))
- )
- )
- (command "_.undo" "_BE" "_.-xref" "_B" "*" "_.-layer" "_U" "*" "")
- (sssetfirst nil (ssget "_X" (list '(0 . "INSERT") (cons 2 (apply 'strcat (cdr a))))))
- (c:burst)
- (while (setq d (tblnext "LAYER" (null d)))
- (if
- (or
- (minusp (cdr (assoc 62 d)))
- (= 1 (logand 1 (cdr (assoc 70 d))))
- )
- (setq e (cons (cdr (assoc 2 d)) e))
- )
- )
- (command "_.-laydel")
- (foreach x e (command "_N" x))
- (command "" "_Y" "_.-layer" "_C" "55" "*" "")
- (if (setq f (ssget "_X" '((0 . "*DIMENSION"))))
- (command "_.erase" f "")
- )
- (if (setq f (ssget "_X"))
- (command "_.chprop" f "" "_C" "ByLayer" "")
- )
- (command "_.undo" "_E")
- (setvar 'CMDECHO c)
- (princ)
- )
但是要小心,上面的代码很危险,因为它使用LayDel命令,该命令将在删除某个层之前删除该层上的所有实体。 |