将一个图块的某个属性,复制给其他图块的同名属性;
这个例子是将:文字图块:阀门位号属性值KV-20710810值,赋值给支架图块的阀门位号属性(隐藏)
(defun c:copy_weihao ()
(setq ss3 "")
(setq stxt "阀门位号")
;将阀门位号属性同步到其他图块的同名属性中去
(setq sname (ssname (ssget) 0))
(setq ent(entget sname))
(setq ent1 ent)
(setq ss (cdr (assoc -1 ent1)))
;获取文字图块的阀门位号属性值;
(IF (/= "SEQEND" (cdr (assoc 0 ENT)))
(WHILE
(= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(cond
((= (CDR (ASSOC 2 ENT1)) stxt)
(setq ss3 (cdr (assoc 1 ent1)))
)
)
)
)
;将文字图块的阀门位号属性值,重复更新给选中的单个对象
(WHILE
(setq SS1 (ssget))
(IF SS1
(Repeat (SsLength SS1)
(progn
(Setq Blockname (SsName SS1 0))
(SsDel blockname SS1)
(setq ent(entget blockname))
(setq ent1 ent)
(setq ss (cdr (assoc -1 ent1)))
(IF (/= "SEQEND" (cdr (assoc 0 ENT)))
(WHILE
(= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(cond
((= (CDR (ASSOC 2 ENT1)) stxt)
(SETQ ENT1 (SUBST (CONS 1 (strcat ss3)) (ASSOC 1 ENT1) ENT1))
(ENTMOD ENT1)
)
)
)
)
)
)
)
))
(DEFUN C:GW()
(c:copy_weihao)
)