- ;;;给文字下划线 carrot1983 2008-1-6
- (vl-load-com)
- (defun c:underLine (/ E ELST I O SS STR V0 V1 V2 VALUE)
- ;;ss2Elst选择集->图元表
- (defun ss2Elst (ss / elst)
- (setq i 0)
- (repeat (sslength ss)
- (setq elst (cons (ssname ss i) elst)
- i (1+ i)
- ) ;_ end setq
- ) ;_ end repeat
- (reverse elst)
- ) ;_ end defun
- (defun getValue (ename code)
- (setq value (cdr (assoc code (entget ename))))
- ) ;_ end defun
- (defun replaceValue (e code val / data)
- (setq data (entget e))
- (setq data (subst (cons code val) (assoc code data) data))
- (entmod data)
- ) ;_ end defun
- (setq ss (ssget '((-4 . "<or")
- (0 . "*TEXT,DIMENSION,ATTDEF")
- (-4 . "<and")
- (0 . "INSERT")
- (66 . 1)
- (-4 . "and>")
- (-4 . "or>")
- )
- ) ;_ end ssget
- ) ;_ end setq
- (setq elst (ss2Elst ss))
- (foreach e elst
- (setq v0 (getValue e 0)
- v1 (getValue e 1)
- v2 (getValue e 2)
- ) ;_ end setq
- (cond
- ((and (wcmatch v0 "TEXT")
- (/= "%%u" (strcase (substr v1 1 3) T))
- ) ;_ end and
- (replaceValue e 1 (strcat "%%u" v1))
- )
- ((and (wcmatch v0 "MTEXT") (not (VL-STRING-SEARCH "\\L" v1)))
- (replaceValue e 1 (strcat "{\\L" v1 "}"))
- )
- ((and (wcmatch v0 "DIMENSION")
- (not (VL-STRING-SEARCH "\\L" v1))
- ) ;_ end and
- (if (= v1 "")
- (replaceValue e 1 (strcat "{\\L" "<>" "}"))
- (replaceValue e 1 (strcat "{\\L" v1 "}"))
- ) ;_ end if
- )
- ((and (wcmatch v0 "ATTDEF")
- (/= "%%u" (strcase (substr v2 1 3) T))
- ) ;_ end and
- (replaceValue e 2 (strcat "%%u" v2))
- )
- ((wcmatch v0 "INSERT")
- (progn
- (setq o (vlax-ename->vla-object e))
- (setq str (vla-get-TextString
- (car (vlax-safearray->list
- (vlax-variant-value (vla-GetAttributes o))
- )
- )
- )
- )
- (if (/= "%%u" (strcase (substr str 1 3) T))
- (vla-put-TextString
- (car (vlax-safearray->list
- (vlax-variant-value (vla-GetAttributes o))
- )
- )
- (strcat "%%u" str)
- )
- ) ;_ end if
- ) ;_ end progn
- )
- ) ;_ end cond
- ) ;_ end foreach
- (princ)
- ) ;_ end defun
- (defun c:tt ()
- (c:underLine)
- ) ;_ end defun
|