PDA

View Full Version : Routine to change text styles


amanda_duvall
2007-10-04, 03:23 PM
How can I create a macro or autolisp to toggle between two different text styles? For example, when working in a drawing I want all text to be Romans, but when I'm ready to submit the drawing it needs to be Times New Romans. Is this even possible?

BrenBren
2007-10-04, 03:31 PM
How can I create a macro or autolisp to toggle between two different text styles? For example, when working in a drawing I want all text to be Romans, but when I'm ready to submit the drawing it needs to be Times New Romans. Is this even possible?

Instead of changing all the text to a different text style, why don't you change your text style to be a different font?

I'm not sure how to do that as a macros, but since it would be one simple step, I'm not sure you need it.

tedg
2007-10-04, 05:20 PM
Instead of changing all the text to a different text style, why don't you change your text style to be a different font?

I'm not sure how to do that as a macros, but since it would be one simple step, I'm not sure you need it.
As BrenBren wrote, It would be best to set up a text style and change the fonts associated to it.
Lets say you have a text style called "STD_TXT" then you could change the font, and all text using this style would change (provided it wasn't over-ridden in an mtext dialog or something).

With that said, you could use this lisp routine
(the commands are "ROMANS" and "TIMES"):

(defun c:ROMANS ()
(command "_style" "STD_TXT" "romans.shx" "" "" "" "" "" "")
)
(defun c:TIMES ()
(command "_style" "STD_TXT" "times.ttf" "0" "1" "" "" "" "")
)


I didn't test it but pretty sure this will work, I wrote one like it using other fonts.
It's a pretty simple routine.

Good luck

RobertB
2007-10-04, 06:47 PM
Have you considered that text width will most likely change, and in some cases, radically.

d_m_hopper
2007-10-04, 07:00 PM
How can I create a macro or autolisp to toggle between two different text styles? For example, when working in a drawing I want all text to be Romans, but when I'm ready to submit the drawing it needs to be Times New Romans. Is this even possible?

just in case you want to know what else you can change

(defun c:ROMANS ()
(command "_style" "text style" "ttf or shx" "height" "width factor" "obliquing angle<0>" "text backwards<y/n>" "upside down<y/n>" "vertical<y/n>")
)

letters in red are default, that is why your code was finished this way"" "" "" "")

(defun c:ROMANS ()
(command "_style" "STD_TXT" "romans.shx" "" "" "" "" "" "")
)
(defun c:TIMES ()
(command "_style" "STD_TXT" "times.ttf" "0" "1" "" "" "" "")
)

tedg
2007-10-04, 07:14 PM
just in case you want to know what else you can change

(defun c:ROMANS ()
(command "_style" "text style" "ttf or shx" "height" "width factor" "obliquing angle<0>" "text backwards<y/n>" "upside down<y/n>" "vertical<y/n>")
)letters in red are default, that is why your code was finished this way"" "" "" "")
^^^^^ Yea, what d_m_hopper said...^^^^^
If you need to control any of the text style options, you'll need to put that in your code.
The "" is a keyboard "enter" though the defaults (maybe you know that).