一个简单的嵌套块一炸到底程序,对多重块不起作用:
- (defun c:tt (/ olderr *error* blk ss ss1)
- (setq olderr *error*)
- (defun *error* (msg)
- (setvar "qaflags" 0)
- (princ msg)
- (princ)
- )
- (setvar "qaflags" 1)
- (if (and
- (setq blk (car (entsel "\n选择图块:")))
- (= "INSERT" (cdr (assoc 0 (entget blk))))
- )
- (progn
- (setq ss (ssadd blk)
- cnt (sslength ss)
- Flag t
- )
- (while (and Flag
- (/= cnt
- (sslength
- (progn
- (command "_explode" ss "")
- (setq ss1 (ssget "_P"))
- (if ss1
- (setq ss ss1)
- ss
- )
- )
- )
- )
- )
- (repeat (setq n (sslength ss))
- (setq en (ssname ss (setq n (1- n))))
- (if (/= "INSERT" (cdr (assoc 0 (entget en))))
- (ssdel en ss)
- )
- )
- (setq cnt (sslength ss))
- (if (= 0 cnt)
- (setq Flag nil)
- )
- )
- )
- )
- (setvar "qaflags" 0)
- (setq *error* olderr)
- (princ)
- )
|