
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have this small lisp routine that replaces old text "JKT @ MUD" with a new text "MUDLINE" :
(setq tss2 (ssget "_X" '((0 . "TEXT,MTEXT"))))
(repeat (sslength tss2)
(setq tdata (entget (ssname tss2 0)))
(if (= (strcase "JKT@MUD") (strcase (cdr (assoc 1 tdata))))
(entmod (subst (cons 1 "MUDLINE") (assoc 1 tdata) tdata))
); end if
(ssdel (ssname tss2 0) tss2)
); end repeat
This routine was to be a small part of a larger lisp routine that will modify our drawings to a new company-wide standard.
I thought this worked perfect for my needs until I realized that the old text is not always just "JKT @ MUD ".
Often the string is accompanined by a number... for example "JKT @ MUD (-40') "... thus the old string is not found and no change is made.
How can this be modified to find all instances of the old string, that may or may not include the attached number, and replace the old portion of that string with the new text? YET still retain the attached number, if it exists, so we do not lose it as part of the string ... for example "MUDLINE (-40') "?
I do not wish for the routine to halt and ask me to enter or pick text to change and enter or pick text to replace it with as these values will be hard coded.
I wish it to act globally on all text and mtext. It is not necessary to work on dimensions or attributed blocks.
I know AutoCAD's built in Find and Replace can do this with wildcard characters, but again I need a lisp so it will be automatic as there are many instances in each drawing AND I have several other variable text strings that need this same routine copied/modified inside the larger lisp so that their individual strings will change also.
Thank you for any help you can provide.
Solved! Go to Solution.