图块替换需要那么长的代码么? 我这里有个简单点的,能保留原有块的大小、方向,只是属性块的属性没有考虑。
- (defun rpblock(ename blockname / ell)
- (setq ell (entget ename))
- (setq ell (subst (cons 2 blockname) (assoc 2 ell) ell))
- (entmod ell)
- (entupd ename)
- )
- (defun c:kth( / ss i tename blockname ename)
- (setq ss (ssget '((0 . "INSERT")))
- i 0
- );setq
- (if ss
- (progn
- (princ "\n请选择块:")
- (while (/= "INSERT" (cdr (assoc 0 (entget (setq tename (car (entsel)))))))
- (princ "\n请选择块:")
- )
- (setq blockname (cdr (assoc 2 (entget tename))))
- (repeat (sslength ss)
- (setq ename (ssname ss i) i (+ 1 i))
- (rpblock ename blockname)
- )
- )
- )
- (princ)
- )
|