MTEXT - Set Text Style and Layer While Still Typing in Model Space

MTEXT - Set Text Style and Layer While Still Typing in Model Space

Anonymous
Not applicable
1,493 Views
5 Replies
Message 1 of 6

MTEXT - Set Text Style and Layer While Still Typing in Model Space

Anonymous
Not applicable

I'm trying to create a lisp that will 1) change my layer to  "2D_TEXT", 2) set my text style, 3) run "mtext" and set the width to 0, and then return to the previous layer. I've got it to do all of that, however, when I run the routine all the text being typed displays in the command bar and not in model space. Is there a way to accomplish all this AND get the text to appear in model space as it's being typed?

 

Here is my code:

 

(defun c:mlinetext ( / curlayer)
(setq curlayer (getvar 'clayer))
(command "-layer" "_m" "2D_TEXT" "")
(command-s "._textstyle" "annotative")
(command "._mtext" "\\" "w" "0")
(setvar 'clayer curlayer)
(princ)
)

0 Likes
Accepted solutions (1)
1,494 Views
5 Replies
Replies (5)
Message 2 of 6

Ranjit_Singh
Advisor
Advisor
Accepted solution

@ВeekeeCZ posted a solution here. Implementing his idea below

(defun c:mlinetext ( / curlayer)
(setq curlayer (getvar 'clayer))
(command "-layer" "_m" "2D_TEXT" "")
(command-s "._textstyle" "annotative")
(command "_.mtext" "_none" (getpoint) "_none" "@" "")
(command "_mtedit" "l")
(setvar 'clayer curlayer)
(princ)
)
Message 3 of 6

scot-65
Advisor
Advisor
Yea, MText is a little stubborn inside a custom program...

Another possibility - R2016:
Substitute what you have with this line [as a start] and give it a try...
(initdia)(command ".MTEXT")(command pause) "L" "E" "1x" (command pause)

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

Message 4 of 6

Anonymous
Not applicable

Scot-65,

 

So, replacing the MTEXT line with the command string you posted still requires me to provide a window size for the text. It did, however, still bring up the dialog box for MTEXT in the drawing space.

0 Likes
Message 5 of 6

Anonymous
Not applicable

Is there a way to undefine MTEXT and redefine it with the new MLINETEXT? And if it were redefined would any references of MTEXT, whether it's in an icon or typed out, would it use MLINETEXT?

 

I appreciate all the help and I'm learning more each time I post. Thanks everyone for the help and input.

0 Likes
Message 6 of 6

Anonymous
Not applicable

Never mind. I figured it out. Not as difficult as I thought...

 

(command "undefine" "mtext")

(defun c:mtext ( / curlayer)
(setq curlayer (getvar 'clayer))
(command "-layer" "_m" "2D_TEXT" "")
(command-s "._textstyle" "annotative")
(command "_.mtext" "_none" (getpoint) "_none" "@" "")
(command "_mtedit" "l")
(setvar 'clayer curlayer)
(princ)
)

0 Likes