Turn all Mtext to text font SansSerif, and underline

Turn all Mtext to text font SansSerif, and underline

skchui6159
Advocate Advocate
646 Views
8 Replies
Message 1 of 9

Turn all Mtext to text font SansSerif, and underline

skchui6159
Advocate
Advocate

Can any body help, how can I change the all Mtext's text font to SabSerif/romand and underline in current view with lisp? Thank you

0 Likes
Accepted solutions (2)
647 Views
8 Replies
Replies (8)
Message 2 of 9

hak_vz
Advisor
Advisor
Accepted solution

1) Create text style named SansSerif and select font that you want

2) run following script

(defun c:aaa (/ ss eo i)
	(setq ss (ssget "_X" '((0 . "MTEXT"))) i -1)
	(while (< (setq i (1+ i)) (sslength ss))
	(setq eo (vlax-ename->vla-object (ssname ss i)))
	(vlax-put  eo 'textString(strcat "{\\L" (vlax-get eo 'textString) "}"))
	(vlax-put eo 'StyleName "SansSerif")
	)
	(princ)
)

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 3 of 9

skchui6159
Advocate
Advocate

The above lisp did not work.

skchui6159_0-1728380209850.png

 

skchui6159_1-1728380224878.png

 

0 Likes
Message 4 of 9

hak_vz
Advisor
Advisor

@skchui6159  You have mtext with internally changed font. Use stripmtext and remove all unnecessary formatting and assigned fonts. Than use my script .

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 5 of 9

hak_vz
Advisor
Advisor
Accepted solution

Alternatively, copy all mtexts to new temp file, select all and explode. Run search and replace %%U with blank.

Convert all texts to mtexts

(defun c:t2m ( / *error* ss i )
	(defun *error* ()
		(setvar 'cmdecho 1)
		(princ)
	)
	(setq ss (ssget '((0 . "TEXT"))) i -1)
	(setvar 'cmdecho 0)
	(while (< (setq i (1+ i)) (sslength ss))
		(command "_.txt2mtxt" (ssname ss i) "")
	)
	(setvar 'cmdecho 1)
	(princ "\nDone!")
	(princ)
)

Use my script above.

 

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
0 Likes
Message 6 of 9

skchui6159
Advocate
Advocate

skchui6159_0-1728394402799.png

What happen about the error:AutoCAD.Application: Key not found? Sloved by rename style, Thank

0 Likes
Message 7 of 9

skchui6159
Advocate
Advocate

The above method works! Good. Thank you very much!

0 Likes
Message 8 of 9

skchui6159
Advocate
Advocate

What is the meaning about %%U?

0 Likes
Message 9 of 9

Kent1Cooper
Consultant
Consultant

@skchui6159 wrote:

What is the meaning about %%U?


Read about it.

Kent Cooper, AIA
0 Likes