相关: attdisp 命令,只能全局打开或关闭属性.本程序可局部控制选中的带属性块的属性显示.
|;
(defun c:xattd (/ k kk ss vss)
(setq *doc (vla-get-activedocument(vlax-get-acad-object))) ;全局.
(initget 0 "V X")
(setq k (getkword "\n 块属性:v-显示 / x-关闭 / <自动切换>"))
(cond
((= k "V")(setq k ':vlax-true))
((= k "X")(setq k ':vlax-false))
)
(while (setq ss (ssget '((0 . "INSERT")(66 . 1)))) ;; 循环选择.
(vla-delete (vla-item (vla-get-selectionsets *doc) 0)) ;;排除bug.
(setq vss(vla-get-activeselectionset *doc))
(vlax-map-collection
vss
'(lambda (x)
(mapcar '(lambda (y)
(if k
(vla-put-Visible y k)
(progn
(if (eq :vlax-false (vla-get-Visible y))
(setq kk ':vlax-true)
(setq kk ':vlax-false)
)
(vla-put-Visible y kk)
)
)
)
(vlax-invoke x 'GetAttributes)
)
)
)
)
(princ)
) 23楼在CAD2002不能运行,<br/>;48--- 关闭属性显示 ---<br/>(DEFUN C:OFFATT()<br/> (IF(AND(PRINC "\\n选择带属性图块 :")<br/> (SETQ SS (SSGET '((0 . "INSERT")(66 . 1))))<br/> )<br/> (PROGN<br/> (SETQ I -1)<br/> (REPEAT(SSLENGTH SS)<br/> (SETQ ENT (ENTGET(SSNAME SS (SETQ I (1+ I))))<br/> ENT1 ENT<br/> )<br/> (WHILE(=(CDR(ASSOC 0 (SETQ ENT1 (ENTGET(ENTNEXT(CDR(ASSOC -1 ENT1))))))) "ATTRIB")<br/> (IF(=(CDR(ASSOC 70 ENT1)) 0)<br/> (PROGN(SETQ ENT1 (SUBST '(70 . 5)(ASSOC 70 ENT1) ENT1))<br/> (ENTMOD ENT1)(ENTMOD ENT)<br/> )<br/> )<br/> )<br/> )<br/> )<br/> )<br/> (PRINC)<br/>)<br/><br/>;49--- 打开属性显示 ---<br/>(DEFUN C:ONATT()<br/> (IF(AND(PRINC "\\n选择带属性图块 :")<br/> (SETQ SS (SSGET '((0 . "INSERT")(66 . 1))))<br/> )<br/> (PROGN<br/> (SETQ I -1)<br/> (REPEAT(SSLENGTH SS)<br/> (SETQ ENT (ENTGET(SSNAME SS (SETQ I (1+ I))))<br/> ENT1 ENT<br/> )<br/> (WHILE(=(CDR (ASSOC 0 (SETQ ENT1 (ENTGET(ENTNEXT(CDR(ASSOC -1 ENT1))))))) "ATTRIB")<br/> (IF(=(CDR(ASSOC 70 ENT1)) 5)<br/> (PROGN(SETQ ENT1 (SUBST '(70 . 0)(ASSOC 70 ENT1) ENT1))<br/> (ENTMOD ENT1)(ENTMOD ENT)<br/> )<br/> )<br/> )<br/> )<br/> )<br/> )<br/> (PRINC)<br/>)<br/><br/>;50--- 属性显示转换 ---<br/>(DEFUN C:ONFATT()<br/> (IF(AND(PRINC "\\n选择带属性图块 :")<br/> (SETQ SS (SSGET '((0 . "INSERT")(66 . 1))))<br/> )<br/> (PROGN<br/> (SETQ I -1)<br/> (REPEAT(SSLENGTH SS)<br/> (SETQ ENT (ENTGET(SSNAME SS (SETQ I (1+ I))))<br/> ENT1 ENT<br/> )<br/> (WHILE(=(CDR (ASSOC 0 (SETQ ENT1 (ENTGET(ENTNEXT(CDR(ASSOC -1 ENT1))))))) "ATTRIB")<br/> (IF(=(CDR(ASSOC 70 ENT1)) 5)<br/> (PROGN(SETQ ENT1 (SUBST '(70 . 0)(ASSOC 70 ENT1) ENT1))<br/> (ENTMOD ENT1)(ENTMOD ENT)<br/> )<br/> (PROGN(SETQ ENT1 (SUBST '(70 . 5)(ASSOC 70 ENT1) ENT1))<br/> (ENTMOD ENT1)(ENTMOD ENT)<br/> )<br/> )<br/> )<br/> )<br/> )<br/> )<br/> (PRINC)<br/>) <p>还用那么麻烦,用文字替代的方法,用"find"标准命令,用"A"代替"B". "B"也可以为空。</p>