;;;-----------------------------------------------------------------------
;;; CTEXT - CHANGE GROUPS OF TEXT AT ONE TIME
;;;-----------------------------------------------------------------------

(defun C:CT (/ p l n e os as ns st s nsl osl sl si chf chm cont)
(setq olderr *error* *error* texterr)
(setq chm 0 p (ssget (list (cons 0 "TEXT"))))
(if p
(progn
(setq cont t)
(while cont
(setq osl (strlen (setq os (getstring "\nOld string: " t))))
(if (= osl 0)
(princ "Null input invalid")
(setq cont nil)
)
)
(setq nsl (strlen (setq ns (getstring "\nNew string: " t))))
(setq l 0 n (sslength p))
(while (< l n)
(if (= "TEXT" (cdr (assoc 0 (setq e (entget (ssname p l))))))
(progn
(setq chf nil si 1)
(setq s (cdr (setq as (assoc 1 e))))
(while (= osl (setq sl (strlen (setq st (substr s si osl)))))
(if (= st os)
(progn
(setq s (strcat (substr s 1 (1- si))
ns (substr s (+ si osl))
)
)
(setq chf t)
(setq si (+ si nsl)))
(setq si (1+ si))
)
)
(if chf
(progn
(setq e (subst (cons 1 s) as e))
(entmod e)
(setq chm (1+ chm))
)
)
)
)
(setq l (1+ l))
)
)
)
(princ (strcat "\nChanged "(itoa chm)" text line(s). "))
(setq *error* olderr)
(princ)
)
(c:ct)

Advertisements