本帖最后由 作者 于 2008-4-23 19:07:20 编辑
;综合明经 ZZXXQQ与晓东 zxq0220的程序如下: ;替换分号后字符 明经 ZZXXQQ 2008.4.21 (defun c:tt2 () (if (setq news (getstring "\nEnter New string 输入新字串 <2]25> :")) (progn (setq news (if (= (strlen news) 0) "2]25" news)) (while (wcmatch news "*`.*") (setq news (chchar news "." "]"))) (if (setq ss (ssget '((0 . "TEXT") (1 . "*;*")))) (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) ent (entget(ssname ss i)) txt (cdr(assoc 1 ent)) j (strlen txt) sl j) (while (and (> j 1) (/= (setq s1 (substr txt j 1)) ";")) (setq j (1- j))) (setq ent (subst (cons 1 (strcat (substr txt 1 j) news)) (assoc 1 ent) ent)) (entmod ent) ) )) )) (princ) ) ;替换分号前字符 明经 ZZXXQQ 2008.4.16 (defun c:tt1 () (if (setq news (getstring "\nEnter New string 输入新字串 <2]25> :")) (progn (setq news (if (= (strlen news) 0) "2]25" news)) (while (wcmatch news "*`.*") (setq news (chchar news "." "]"))) (if (setq ss (ssget '((0 . "TEXT") (1 . "*;*")))) (progn (setq i -1) (repeat (sslength ss) (setq i (1+ i) ent (entget(ssname ss i)) txt (cdr(assoc 1 ent)) j 1 sl (strlen txt)) (while (and (< j sl) (/= (setq s1 (substr txt j 1)) ";")) (setq j (1+ j))) (setq ent (subst (cons 1 (strcat news (substr txt j))) (assoc 1 ent) ent)) (entmod ent) ) )) )) (princ) ) ;子程序 ;晓东 zxq0220 2008.4.18 ;明经 ZZXXQQ 2008.4.22修改 (defun chchar (ss eqq wt / s2 tmp i) (setq i 1 tmp "") (while (/= (setq s2 (substr ss i 1)) eqq) (setq tmp (strcat tmp s2) i (1+ i))) (strcat tmp wt (substr ss (1+ i))) ) ; 谢谢ZZXXQQ、zxq0220 |