Here's a draft
- (defun c:FindFrac (/ aDoc OldFrac NewFrac objs sstr strt str _old _new )(vl-load-com) (setq aDoc (vla-get-activedocument (vlax-get-acad-object))) (cond ((and (setq OldFrac (getstring "\nEnter Fraction to Replace: ")) (setq NewFrac (getstring "\nEnter New Fraction to Substitute: ")) (ssget ":L" '((0 . "MTEXT"))) (vlax-for txts (setq objs (vla-get-activeselectionset aDoc)) (setq sstr (vla-get-textstring txts) strp 1) (while (setq strt (vl-string-search "[url="file://\\S"]\\S[/url]" sstr strp)) (setq _old OldFrac _new NewFrac) (setq str (substr (setq val (substr sstr (+ strt 3))) 1 (vl-string-search ";" val))) (if (vl-string-search "#" str) (setq _new (vl-string-subst "#" "/" _new) _old (vl-string-subst "#" "/" _old))) (if (equal _old str) (progn (setq sstr (vl-string-subst _new str sstr)) (vla-put-textstring txts sstr)) ) (setq strp (+ strt 3)) ) ) (vla-delete objs) ) ) ) (princ) )
command: _FindFrac
Enter Fraction to Replace: 1/8
Enter New Fraction to Substitute: 3/4
select objects:
I works exclusively on MTEXT with stacked format. (horizonatl/diagonal)
You may wonder what this line is for (setq _old OldFrac _new NewFrac). some of our guys here tends to combine diagonal and vertical stacking on one pharagraph/sentence. the value "/" will be change to "#" once the if statement is true and revert back to "/" after the loop (its one or the other)
For your comments and suggestions.
Need you guys to try it out so i can make improvements...
Cheers |