(defun tferr (msg) (if clr (setvar "cecolor" clr)) (if os (setvar "osmode" os)) (if ol (setvar "clayer" ol)) (setq *error* olderr) (if (null linesdrawn)(princ "\nNo match found!")) (command "_.undo" "_end") (princ) ) ;TF.LSP v1.5 now includes MTEXT and finds 1-character strings. Added error-checker. (defun c:tf (/ linesdrawn clr os ol seektxt seeklen alltext allmtext cnt mcnt remainder e1 foundtxt foundlen foundtxtm foundlenm elist) (command "_.undo" "_g") (setq olderr *error* *error* tferr) (setq os (getvar "osmode")) (setq clr (getvar "cecolor")) (setq ol (getvar "clayer")) (setvar "osmode" 0) (command ".layer" "t" "0" "s" "0" "") (command "_.color" "cyan") (setq seektxt (strcase (getstring T"\nFind what text? \n" ))) (terpri) (setq seeklen (strlen seektxt)) (setq alltext (ssget "X" (list (cons 0 "TEXT")))) (setq cnt (sslength alltext)) (setq remainder cnt) (setq e1 (ssname alltext 0)) (while (> remainder 0) (setq e1 (ssname alltext (- cnt remainder))) (setq remainder (1- remainder)) (setq elist (entget e1)) (setq foundtxt nil) (setq foundtxt (cdr (assoc '1 elist))) (setq foundlen (strlen foundtxt)) (While (and; this doesn't make sense to me, but it works! (> foundlen 1) (setq foundlen (- foundlen 1)) (substr foundtxt foundlen)) (if (= (substr (strcase foundtxt) foundlen seeklen) seektxt) (progn (command ".line" (getvar "viewctr") (trans (cdr (assoc 10 elist)) 0 1) "") (setq linesdrawn T) ) ) );end while (if (= foundlen 1) (if (= (strcase foundtxt) (strcase seektxt)) (progn (command ".line" (getvar "viewctr") (trans (cdr (assoc 10 elist)) 0 1) "") (setq linesdrawn T) ) ) );end while ) (setq allmtext (ssget "X" (list (cons 0 "MTEXT")))) (if allmtext (setq mcnt (sslength allmtext))) (setq remainder mcnt) (if allmtext (setq e1 (ssname allmtext 0))) (while (and allmtext (> remainder 0)) (setq e1 (ssname allmtext (- mcnt remainder))) (setq remainder (1- remainder)) (setq elist (entget e1)) (setq foundtxtm nil) (setq foundtxtm (cdr (assoc '1 elist))) (setq foundlenm (strlen foundtxtm)) (While (and (> foundlenm 1) (setq foundlenm (- foundlenm 1)) (substr foundtxtm foundlenm)) (if (= (substr (strcase foundtxtm) foundlenm seeklen) seektxt) (progn (command ".line" (getvar "viewctr") (trans (cdr (assoc 10 elist)) 0 1) "") (setq linesdrawn T) ) ) ) (If (and (= foundlenm 1) (= (strcase foundtxtm) (strcase seektxt)) ) (progn (command ".line" (getvar "viewctr") (trans (cdr (assoc 10 elist)) 0 1) "") (setq linesdrawn T) ) );end if ) (setvar "osmode" os) (setvar "clayer" ol) (setvar "cecolor" clr) (if c:r (c:r)) (command "_.undo" "_end") (setq *error* olderr) (if (null linesdrawn)(princ "\nNo match found!")) (princ) ) (princ "\nTF.lsp V1.5 Loaded")