I often use the "Find & Replace" function and everytime i have to fill in find word and replace word. if therer ten words need be replace and 20 more drawings have the same words, i have to spend a lot of time. I think there should be a table in which find words list in left side and replace words in right side, when i hit the RUN button, there words changed in second.
Thanks,
Peter
Try this code it's not mine though
;;------------------------------------------------;; (defun C:FRTT(/ elist filter found i matches matchlst newstr oldtext sset tf txt) ;; helpers ;; written by Tony Tanzillo © ;; ;; (string-subst ) ;; ;; Replaces first occurrance of with ;; in ;; ;; Example: ;; ;; (String-subst ;; "Eleven" ;; "Seven" ;; "Four Score and Seven Years Ago" ;; ) ;; ;; Returns -> "Four Score and Eleven Years Ago" (defun String-subst (new old str / i l) (if (setq i (StrPos old str)) (strcat (substr str 1 (1- i)) new (substr str (+ i (strlen old))) ) str ) ) (defun strpos (sub str / l wl i c) (setq l (strlen str) wl (1+ (- l (strlen sub))) i 0 c (substr sub 1 1) ) (while (and (>= wl (setq i (1+ i))) (or (/= (substr str i 1) c) (not (strlcmp sub (substr str i)))) ) ) (if (>= wl i) i) ) (defun Strlcmp (prefix string) (eq prefix (substr string 1 (strlen prefix))) ) ;; Use VLISP if available: ;;;(if vl-string-subst ;;;(setq string-subst vl-string-subst) ;;;) ;; you have to create list of pairs kind of '(newstring . oldstring) ;; may write them as delimited text file usualy separated by semocolon before, ;; then read this file and build your match list, (here is just a dummy one for test): (setq matchlst '(("newstring1" . "oldstring1")("newstring2" . "oldstring2");| ETC ...|;("newstringN" . "oldstringN"))) (setq filter (mapcar 'cdr matchlst)) (setq matches (mapcar 'car matchlst)) (setq tf "") (foreach item filter (setq tf (strcat tf "*" item "*,"))) (setq filter (substr tf 1 (1-(strlen tf)))) (if (setq sset (ssget "_X" (list (cons 0 "*text")(cons 1 filter))));< -- select all texts and mtexts (progn (setq i 0) (repeat (sslength sset) (setq txt (ssname sset i) elist (entget txt)) (setq oldtext (cdr (assoc 1 elist))) (if (setq found (car (vl-remove-if-not '(lambda (x)(vl-string-search x oldtext )) (mapcar 'cdr matchlst)))) (progn (setq newstr (nth (vl-position found (mapcar 'cdr matchlst))matches)) (setq elist (subst (cons 1 (string-subst newstr found oldtext))(assoc 1 elist) elist)) (entmod elist))) (setq i (1+ i))) ) ) (princ) ) (princ "\nStart command with FRTT ...") (prin1) ;;----------------------------------------------------------------------;;
Click orange button at the very left bottom of this page
and copy code from there completely, then paste in
Notepad and save with .lsp extension, say "findrep_TT.lsp"
then just type FRTT in the command line after aploading the file
usual way from Tools->AutoLisp->Load application
wait 20 minutes or so please,
will be back soon
Try attached, tested om my A2010 with success
either with text and mtext
My screen is like below:
Command:
Command: APPLOAD FindReplace_TT.LSP successfully loaded.
Command: Start command with FRTT ...
Command:
Command: FRTT
Command: