lupita6 Posted April 6, 2012 Share Posted April 6, 2012 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 Quote Link to comment Share on other sites More sharing options...
pBe Posted April 6, 2012 Share Posted April 6, 2012 BFind_LeeMac Allows you to Find and Replace multiple words on multiple files. Kudos to Lee Mac Quote Link to comment Share on other sites More sharing options...
Tharwat Posted April 6, 2012 Share Posted April 6, 2012 Be careful to have all strings not on locked layers (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) ) Quote Link to comment Share on other sites More sharing options...
irneb Posted April 6, 2012 Share Posted April 6, 2012 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: (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)) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.