- ;选择图块
- (defun c:xk (/ ss n ent blk blks lst->str)
- (defun lst->str ( lst del / str )
- (setq str (car lst))
- (foreach itm (cdr lst) (setq str (strcat str del itm)))
- str
- )
- (princ "\n选择源图块<可多选>:")
- (if (setq ss (ssget '((0 . "INSERT"))))
- (progn
- (setq blks nil)
- (setq n -1)
- (repeat (sslength ss)
- (setq ent (ssname ss (setq n (1+ n))))
- (setq blk (cdr (assoc 2 (entget ent))))
- (if (not (member blk blks))
- (setq blks (cons blk blks))
- )
- )
- (if (and (setq blks (lst->str blks ",")) (setq ss (ssget (list (cons 2 blks)))))
- (progn
- (sssetfirst nil ss)
- (princ (strcat "\n共选中了" (itoa (sslength ss)) "个图块。"))
- )
- )
- )
- )
- (princ)
- )
- ;选择图块-全图
- (defun c:xka (/ ss n ent blk blks lst->str)
- (defun lst->str ( lst del / str )
- (setq str (car lst))
- (foreach itm (cdr lst) (setq str (strcat str del itm)))
- str
- )
- (princ "\n选择源图块<可多选>:")
- (if (setq ss (ssget '((0 . "INSERT"))))
- (progn
- (setq blks nil)
- (setq n -1)
- (repeat (sslength ss)
- (setq ent (ssname ss (setq n (1+ n))))
- (setq blk (cdr (assoc 2 (entget ent))))
- (if (not (member blk blks))
- (setq blks (cons blk blks))
- )
- )
- (if (and (setq blks (lst->str blks ",")) (setq ss (ssget "x" (list (cons 2 blks)))))
- (progn
- (sssetfirst nil ss)
- (princ (strcat "\n共选中了" (itoa (sslength ss)) "个图块。"))
- )
- )
- )
- )
- (princ)
- )
|