Change MText content and formating

Change MText content and formating

hythamthelove
Advocate Advocate
405 Views
4 Replies
Message 1 of 5

Change MText content and formating

hythamthelove
Advocate
Advocate

Hello everyone, i have this Mtext "t=400" i want to change it to "Drop Cap" then under it "THK.=400mm" (as the attached screenshot). I have a lot of Mtexts not just one and it is not always t=400 it may be any other number and i want it to change to the same format and at once by any sort of a lisp. Sample file will be provided.

 

Thanks in advance.

 

hythamthelove_0-1661185881224.png

 

0 Likes
Accepted solutions (1)
406 Views
4 Replies
Replies (4)
Message 2 of 5

ronjonp
Mentor
Mentor

FIND and replace ?

ronjonp_0-1661189963813.png

Then to change the width globally:

ronjonp_0-1661190129367.png

Open the properties palette and change width to 2500 or something.

 

0 Likes
Message 3 of 5

hythamthelove
Advocate
Advocate

it is not 1 text there is a lot of texts and it is not always "t=400", it t= any other number i want the format to change as well

0 Likes
Message 4 of 5

Kent1Cooper
Consultant
Consultant
Accepted solution

How about this?  In simplest terms, minimally tested:

(defun C:YourCommandName (/ tss n tobj num)
  (if (setq tss (ssget "_X" '((1 . "t=#*"))))
    (repeat (setq n (sslength tss))
      (setq
        tobj (vlax-ename->vla-object (ssname tss (setq n (1- n))))
        num (substr (vla-get-TextString tobj) 3)
      ); setq
      (vla-put-Width tobj 0)
      (vla-put-TextString tobj (strcat "Drop Panel\\PTHK.=" num "mm"))
    ); repeat
  ); if
  (princ)
)

Change "YourCommandName" to whatever you would like it to be.  It assumes no internal formatting in the Mtext content [unless it comes after the "t=" part], and that there will be no others starting with "t=" that you do not want changed in this way, and that what follows that is always appropriate content [representing a number] to put into the expanded format.  Variations from those assumptions can probably be accounted for, if necessary.

Kent Cooper, AIA
0 Likes
Message 5 of 5

hythamthelove
Advocate
Advocate

Thank you so much. Really appreciated

0 Likes