本帖最后由 自贡黄明儒 于 2022-11-6 09:55 编辑
- ;;格式刷MA的改进,当选择块时,执行Maa效果
- ;;1 将"块b2"按照"块b1"模样改造,从此"块b1"有两个名字,"块b1"和"块b2"
- (defun maa (NAME OLDNAME / E0 E1)
- (setq e1 (TBLOBJNAME "block" name))
- (setq e0 (TBLOBJNAME "block" oldname))
- ;;重新定义e1
- (entmake (entget e1))
- (while (setq e0 (entnext e0))
- (entmake (entget e0))
- )
- (entmake '((0 . "ENDBLK")))
- ;;; ;;更新显示
- ;;; (setq s (ssget "X"
- ;;; (list '(0 . "INSERT")
- ;;; '(100 . "AcDbBlockReference")
- ;;; (cons 2 name)
- ;;; )
- ;;; )
- ;;; )
- ;;; (repeat (setq n (sslength s))
- ;;; (entupd (ssname s (setq n (1- N))))
- ;;; )
- )
- (defun C:maa (/ NAME OLDNAME)
- (setq oldname (cdr (assoc 2 (entget (car (entsel "\n 源块"))))))
- (setq name (cdr (assoc 2 (entget (car (entsel "\n 被改变的块"))))))
- (maa oldname name)
- (princ)
- )
- ;;2 如果只是将"块b2"按照"块b1"模样改造,"块b2"还是"块b2",慢简单一些
- (defun C:maa1 (/ EN OLDNAME)
- (setq oldname (cdr (assoc 2 (entget (car (entsel "\n 源块"))))))
- (setq en (entget (car (entsel "\n 被改变的块"))))
- (entmod (subst (cons 2 oldname)(assoc 2 en)en))
- (princ)
- )
|