配合晓东zxq0220的子程序,下面程序cad2004测试无反应,不知何故,不支持“]”号。 ;替换分号后字符 明经 ZZXXQQ 2008.4.20 (defun c:tt () (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) ) (defun chchar (ss eqq wt / tmp i) ;;晓东 zxq0220 2008.4.18
(setq i 1 tmp "") (while (/= (setq s2 (substr ss i 1)) eqq) (setq tmp (strcat tmp s2) i (1+ i))) (strcat tmp wt (substr s1 (1+ i))) ) |