Allows you to Find and Replace multiple words on multiple files.
Kudos to Lee Mac
Very good to the community and congratulations on your success,
needed a little help to create a simple lisp routine. This is a lisp that allows me to change the words of a drawing: "Escala" for "Scale" and "Parte" for "Piece" no more. Only a change of words in the file, without having to select objects or anything.
I know the Find and Replace Command, (its great), but I need this routine to apply it to 200 DWGS with EZscript-Pro.
I do not mind changing the words of the routine every time I apply.
Thank you very much and live all the experts in CAD
Be careful to have all strings not on locked layers
Code:(defun c:TesT (/ ss i sn) (if (setq ss (ssget "_x" '((0 . "*TEXT") (1 . "Escala,Parte")))) (repeat (setq i (sslength ss)) (setq sn (ssname ss (setq i (1- i)))) (cond ((eq (cdr (assoc 1 (entget sn))) "Escala") (entmod (subst (cons 1 "Scale") (assoc 1 (entget sn)) (entget sn)) ) ) (t (entmod (subst (cons 1 "Piece") (assoc 1 (entget sn)) (entget sn)) ) ) ) ) (princ) ) (princ) )
- When aim is being settled in my mind , I have to reach it and get it in hand whatever it costs and wherever it is and will never give up . Tharwat said
Registered forum members do not see this ad.
Or if you don't want to use Lee's and the words are only part of the text (instead of the whole text). Also if string case should be ignored:Code:(vl-load-com) (defun c:TextRepl (/ pat str ss s p) (if (and (setq pat (getstring t "\nEnter string to search for: ")) (setq str (getstring t "Enter replacement: ")) (ssget (list '(0 . "TEXT,MTEXT") (cons 1 (setq pat (strcat "*" (apply 'strcat (mapcar '(lambda (c) (strcat "[" (strcase c) (strcase c t) "]")) (mapcar 'chr (vl-string->list pat)))) "*"))))) (setq ss (vla-get-ActiveSelectionSet (vla-get-ActiveDocument (vlax-get-acad-object))))) (progn (vlax-for eo ss (setq s (vla-get-TextString eo) p "") (while (wcmatch s pat) (while (not (wcmatch s (substr pat 2))) (setq p (strcat p (substr s 1 1)) s (substr s 2))) (setq p (strcat p str) s (substr s (1+ (/ (- (strlen pat) 2) 4))))) (if (not (eq s "")) (setq p (strcat p s))) (vla-put-TextString eo p)) (vla-Delete ss))) (princ))
Knowledge is proportional to experience, but wisdom is inversely proportional to ego!
My little bit of "wisdom": Hind-sight is useless, unless used to improve the next forethought!