
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I wish to change a specific string of text in my drawings (one drawing at a time) with a substituted string of text.
I want this to act globally on all text in the drawing.
I have a short lisp routine (below) that works well on all text (single line and multiline) in the drawing.
However, it does not work on strings within blocks.
The strings in the blocks are single line and multiline text also (not attributes), yet they are not being found to change them also.
Can anyone provide help in adding to this routine so that it also works on text and multiline text inside blocks.
Below is the lisp I currently use. Note: the "TEXT TO BE FOUND" and the "TEXT TO BE REPLACED" are always static as we are actually just searching the drawing for all instances of a specific name and changing them to a different name.
Also, please know that this will be incorporated into a larger routine that will also change out logos and such; thus, I wish to use a quick lisp routine to doo all the functions. Otherwise, yes I know, I'd use Find/Replace for this.
(vl-load-com)
(defun c:test1 (/ i obj RegExp ss)
(if (setq ss (ssget "_X" '((0 . "MTEXT,TEXT"))))
(progn
(setq RegExp (vlax-get-or-create-object "VBScript.RegExp"))
(vlax-put-property RegExp 'Global actrue)
(vlax-put-property RegExp 'Ignorecase actrue)
(vlax-put-property RegExp 'Multiline actrue)
(vlax-put-property RegExp 'Pattern "TEXT TO BE FOUND")
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(if (vlax-write-enabled-p obj)
(vla-put-textstring obj (vlax-invoke RegExp 'Replace (vla-get-textstring obj) "TEXT TO BE REPLACED"))
)
)
(vlax-release-object RegExp)
)
)
(princ)
)
Thanks for any help you can provide,
Barry Navarre
Solved! Go to Solution.