修改块中文字属性值的程序
<p>图框是一个块,块中的文字是用att定义的,例如:定义的值为:qwer,我现在想用一个命令:如:A,点选一下图框就可以把我想要的文字替换成:asdf<br/></p>;关闭属性显示 ZZXXQQ 2007.11.12
(DEFUN C:CLOSEATT ()
(IF (AND (PRINC "\nSelect Block with attribute 选择带属性图块 :")
(SETQ SS (SSGET '((0 . "INSERT") (66 . 1))))) (PROGN
(SETQ I -1)
(REPEAT (SSLENGTH SS)
(SETQ ENT (ENTGET (SSNAME SS (SETQ I (1+ I))))
ENT1 ENT)
(WHILE (= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(IF (= (CDR (ASSOC 70 ENT1)) 0) (PROGN
(SETQ ENT1 (SUBST '(70 . 5) (ASSOC 70 ENT1) ENT1))
(ENTMOD ENT1)
(ENTMOD ENT)
))
)
)
))
(PRINC)
)
属性块正在学习中这个代码好好学习下 感谢无私分享,供我辈学习成长。
;替换图块属性 ZZXXQQ 2007.10.28
(DEFUN CHATTRIB (OLDATT NEWATT)
(IF (AND (PRINC "\nSelect Block with attribute 选择带属性图块 :")
(SETQ SS (SSGET '((0 . "INSERT") (66 . 1))))) (PROGN
(SETQ I -1)
(REPEAT (SSLENGTH SS)
(SETQ ENT (ENTGET (SSNAME SS (SETQ I (1+ I))))
ENT1 ENT)
(WHILE (= (CDR (ASSOC 0 (SETQ ENT1 (ENTGET (ENTNEXT (CDR (ASSOC -1 ENT1))))))) "ATTRIB")
(IF (= (CDR (ASSOC 1 ENT1)) OLDATT) (PROGN
(SETQ ENT1 (SUBST (CONS 1 NEWATT) (ASSOC 1 ENT1) ENT1))
(ENTMOD ENT1)
(ENTMOD ENT)
))
)
)
))
(PRINC)
)
(DEFUN C:A ()
(IF (AND (SETQ OATT (GETSTRING "\nOld Attrib 原属性 :"))
(SETQ NATT (GETSTRING "\nNew Attrib 新属性 :")))
(CHATTRIB OATT NATT)
)
(PRINC)
)
<p>多谢多谢.</p><p>这个是可以修改块中文字属性值,但是要输入原属性值和新属性值,有点麻烦,还不如我直接双击该块来修改块中的文字.我的原意是输入命令:A,点选一下图框,图框中有qwer的文字就替换asdf</p> <p>重写一下函数就行了。</p><p><font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/DEFUN.htm" target="_black"><font color="#0000ff">DEFUN</font></a>
<font color="#0000ff"><b>C:A</b></font>
<font color="#ff0000">(</font><font color="#ff0000">)</font><br/> <font color="#ff0000">(</font>CHATTRIB "qwer" "asdf"<font color="#ff0000">)</font><br/> <font color="#ff0000">(</font><a href="http://www.mjtd.com/object/autolisp/PRINC.htm" target="_black"><font color="#0000ff">PRINC</font></a><font color="#ff0000">)</font><br/><font color="#ff0000">)</font></p> <strong><font face="Verdana" color="#da2549">多谢ZZXXQQ</font></strong>