前几天要用在论坛没找到,不知是否通用,不足之处请指正.- ;;修改MTEXT多行文字颜色
- (vl-load-com)
- (defun c:tt (/ co i ss edt cb ps typ)
- (setvar "cmdecho" 0)
- (setq co (acad_colordlg 1))
- (setq i -1)
- (prompt "\n请选择文字:")
- (if
- (not
- (equal
- '(nil nil)
- (sssetfirst
- nil
- (setq
- ss
- (ssget (list '(0 . "MTEXT,TEXT")))
- )
- )
- )
- )
- (setq ss (ssget "_:L"))
- )
- (if ss
- (while (setq e (ssname ss (setq i (+ i 1))))
- (setq edt (entget e)
- cb (cdr (assoc 1 edt))
- ps (vl-string-search "\\C" cb)
- typ (= (cdr (assoc 0 edt)) "MTEXT")
- )
- (cond
- ((and ps typ) (ccol-1 cb ps (rtos co 2 0) edt))
- (T (ccol-2 e co))
- )
- )
- )
- (setvar "cmdecho" 1)
- (princ "\n完毕...")
- (princ)
- )
- ;;文字内容、"\\C"关键字序号、色号、图元表
- (defun ccol-1 (cbb b col et / a c d et)
- (setq a (substr cbb (+ b 2) 4)
- c (vl-princ-to-string (read a))
- d (vl-string-subst (strcat "C" col) c cbb)
- )
- (setq
- et (subst (cons 1 d)
- (assoc 1 et)
- et
- )
- )
- (entmod et)
- )
- ;;图元、色号
- (defun ccol-2 (ent ccol / eo)
- (setq eo (vlax-ename->vla-object ent)
- )
- (vla-put-Color eo ccol)
- )
|