来了,伙计。
如果您的字符(G)不是大写字母,则不会替换文本。
- (defun c:Test (/ Nstr ss)
- ; Tharwat 25. 01. 2011
- ; Tested withAutoCAD 2010
- (if (and (setq Nstr
- (getstring "\n Enterg the replacement Text :"))
- (setq ss
- (ssget '((0 . "TEXT,MTEXT"))))
- )
- (
- (lambda (i / ss1 e str GLoc 1st 2nd all)
- (while
- (setq ss1
- (ssname ss (setq i (1+ i))))
- (setq e (entget ss1))
- (setq str
- (cdr (assoc 1 e)))
- (if
- (eq
- nil (setq GLoc
- (vl-string-search "G" str)))
- (entupd
- (cdr (assoc -1
- (entmod (subst (cons 1 str)
- (assoc 1 e)
- e)
- )
- )
- )
- )
- (progn
- (setq 1st
- (substr str 1 GLoc))
- (setq 2nd
- (substr str (+ 2 GLoc)))
- (setq all
- (strcat 1st Nstr 2nd))
- (entupd
- (cdr (assoc -1
- (entmod (subst (cons 1 all)
- (assoc 1 e) e)
- )
- )
- )
- )
- )
- )
- )
- )
- -1
- )
- (princ "\n No texts selected")
- )
- (princ)
- )
塔瓦特 |