|
改变多行文字的颜色为指定的颜色色号
- (defun m1 (MTextString / regex s)
- (setq regex (vlax-create-object "Vbscript.RegExp"))
- ;引用正则表达式控件
- (vlax-put-property regex "IgnoreCase" 0) ;不忽略大小写
- (vlax-put-property regex "Global" 1) ;匹配方式,全文字匹配
- (setq s MTextString)
- (vlax-put-property regex "Pattern" "(\\\\c|\\\\C)(.[^;]*);")
- (setq s (vlax-invoke-method regex "Replace" s ""))
- (vlax-release-object regex)
- s
- )
- (defun c:tt (/ SS COR I E ENT MT)
- (SETQ SS (SSGET '((0 . "MTEXT"))))
- (IF (NOT SS)
- (VL-EXIT-WITH-VALUE 0)
- )
- (if (or (not cor11) (<= cor11 0) (> cor11 256))
- (setq cor11 1)
- )
- (SETQ COR NIL)
- (WHILE (or (not cor) (<= cor 0) (> cor 256))
- (IF
- (NOT (SETQ
- COR (GETINT (STRCAT "\n请输入颜色号<" (RTOS COR11 2 0) ">"))
- )
- )
- (SETQ COR COR11)
- (SETQ COR11 COR)
- )
- )
- (SETQ I 0)
- (REPEAT (SSLENGTH SS)
- (SETQ E (SSNAME SS I)
- ENT (ENTGET E)
- MT (CDR (ASSOC 1 ENT))
- MT (M1 MT)
- i (1+ I)
- )
- (setq ent (ENTMOD (SUBST (CONS 1 MT) (ASSOC 1 ENT) ENT))
- ent (ENTMOD (SUBST (CONS 62 COR) (ASSOC 62 ENT) ENT))
- )
- )
- (PRINC)
- )
复制代码 |
|