- (defun myerr (s)
- (if (/= s "Function cancelled")
- (princ (strcat "\nError: " s))
- )
- (setq tset nil) ; Free selection set
- (setq *error* olderr)
- (princ)
- )
- (defun C:texsrch (/ tset l n e os as ns st s nsl osl sl si chf chm olderr)
- (setq
- olderr *error*
- *error* myerr
- chm 0
- )
- (menucmd "S=SELECT")
- (prompt "\nSelect Text To Modify <All>: ")
- (if (null (setq tset (ssget)))
- (setq tset (ssget "x" (list (cons 0 "TEXT"))))
- )
- (menucmd "S=")
- (cond
- ((null tset) (prompt "\nNo Text Located in Drawing."))
- (t (terpri)
- (princ (itoa (sslength tset)))
- (prompt " Text Entities Selected.")
- (command "undo" "mark")
- )
- )
- (cond
- ((null tset) (prompt "\nNothing Modified."))
- (t
- (while (= 0 (setq osl (strlen
- (setq os (getstring t "\nOld string: ")))))
- (princ "Null input invalid")
- )
- (setq nsl (strlen (setq ns (getstring t "\nNew string: "))))
- (setq l 0 n (sslength tset))
- (while (< l n)
- (if (= "TEXT" (cdr (assoc 0 (setq e (entget (ssname tset l))))))
- (progn
- (setq
- chf nil
- si 1
- 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 "Changed ")
- (princ chm)
- (prompt " text lines.")
- )
- )
- (setq *error* olderr)
- (princ)
- )
|