- (defun c:blkreplace (/ oldblk newblk ss cnt)
- (setq oldblk (car (entsel "
- 选择要替换的原图块:")))
- (if oldblk
- (progn
- (setq newblk (car (entsel "
- 选择新图块:")))
- (if newblk
- (progn
- (setq ss (ssget "X" (list (cons 0 "INSERT") (cons 2 (cdr (assoc 2 (entget oldblk)))))))
- (setq cnt 0)
- (if ss
- (progn
- (repeat (sslength ss)
- (setq ent (ssname ss (setq i (1+ i))))
- (if (= oldblk (cdr (assoc 2 (entget ent))))
- (progn
- (entmod (subst (cons 2 (cdr (assoc 2 (entget newblk)))) (assoc 2 (entget ent)) (entget ent)))
- (setq cnt (1+ cnt))
- )
- )
- )
- (princ (strcat "
- 共替换了 " (itoa cnt) " 个图块。"))
- )
- (princ "
- 未找到任何符合条件的图块。"))
- )
- (princ "
- 未选择新图块。"))
- )
- (princ "
- 未选择原图块。"))
- (princ)
- )
我是新手,求大神指点,提示参数类型错误,Numberp:nil
|