Mtext Macro with Predetermined text

Mtext Macro with Predetermined text

Kyle.Pederson
Advocate Advocate
1,674 Views
16 Replies
Message 1 of 17

Mtext Macro with Predetermined text

Kyle.Pederson
Advocate
Advocate

I have a Macro:

^C^C_mtext;\R;\W;20;

But I am struggling to understand how to add predetermined text within it, Such as "Drive"

I am looking for this to be a macro and not Lisp.

 

Thanks in advance for help with this.

 

 

0 Likes
Accepted solutions (1)
1,675 Views
16 Replies
Replies (16)
Message 2 of 17

pendean
Community Legend
Community Legend

>>>...I am looking for this to be a macro and not Lisp....<<<
Why post in the LISP forum if you don't want LISP?
Or do you just like to click on a button and don't know LISP can be written into the button macro like just like your LISP free macro?
Or are you an LT user of AutoCAD, no lisp in the program?

 

How about (I did not test this) like it works at the commandline

^C^C_mtext;\R;\W;20;PREDETERMINEDWORDSHERE;;

0 Likes
Message 3 of 17

Kent1Cooper
Consultant
Consultant
Accepted solution

@pendean is close....  I did test, and you need the hyphen prefix.

 

^C^C_.-mtext;\R;\W;20;DRIVE;;

Kent Cooper, AIA
Message 4 of 17

Kent1Cooper
Consultant
Consultant

@pendean wrote:

.... Why post in the LISP forum if you don't want LISP?....


[This is not "the LISP forum" -- see the Forum title.  Command macros certainly fall within the category of "General Customization," as do Hatch Patterns, Linetypes, etc.]

Kent Cooper, AIA
Message 5 of 17

gbG5A5W
Enthusiast
Enthusiast

I tried this for a multiline Mtext, but the macro stops after starting the Mtext-command, waiting for input. My macro:

 

^C^C_.-Mtext;\w;200;Materialisatie:\wit, Kronospan U566 SM\oranje, Unilin 0U272/BST Tiger\hout, Kronospan K004 PW;;

 

The result is that "Materialisatie:" is filled, then it stops. I tried adding a ;, but that's not working either

In the ideal world it would be:

 

Materialisatie:

 

wit, Kronospan U566 SM

oranje, Unilin 0U272/BST Tiger

hout, Kronospan K004 PW

0 Likes
Message 6 of 17

Sea-Haven
Mentor
Mentor

Ok can see a few problems you have not defined the starting point for the MText should be before the "W", next is you need text in Quotes "". Looking at the add line breaks. 

 

Give this a try, note the \n for line breaks.

 

(command "_.-Mtext" (getpoint "\nPick a point for mtext ") "w" 200 "Materialisatie:\nwit, Kronospan U566 SM\noranje, Unilin 0U272/BST Tiger\nPhout, Kronospan K004 PW" "")

 

I find some times easier to make a macro a lisp. Should work as a macro though make sure text is within "......." quotes. Not tested as macro.

0 Likes
Message 7 of 17

gbG5A5W
Enthusiast
Enthusiast

Sorry to say so, but doesn't work as a macro. I get:

 

(getpoint "(command "_.-Mtext" (getpoint "

 

and then  it stops

0 Likes
Message 8 of 17

DGCSCAD
Collaborator
Collaborator

@gbG5A5W wrote:

Sorry to say so, but doesn't work as a macro. I get:

 

(getpoint "(command "_.-Mtext" (getpoint "

 

and then  it stops


Not sure how you got the extra bits on the beginning, but that's not what was posted to copy/paste. Copy/pasting exactly what was posted will yield the correct result.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 9 of 17

Kent1Cooper
Consultant
Consultant

@DGCSCAD wrote:
.... Copy/pasting exactly what was posted will yield the correct result.

... as an AutoLisp function, but not as a command macro.  I'm not sure about the part that you colored red, but I get the rest, and it stops at the same place, because a backslash in a command macro is a pause for User input only.  It doesn't care whether it's within a double-quoted text string, it doesn't function as a special-character trigger as it does in AutoLisp, and a command macro doesn't run AutoLisp functions [as Script can, at least some of them].

Kent Cooper, AIA
0 Likes
Message 10 of 17

DGCSCAD
Collaborator
Collaborator

@Kent1Cooper wrote:

@DGCSCAD wrote:
.... Copy/pasting exactly what was posted will yield the correct result.

... as an AutoLisp function, but not as a command macro.  I'm not sure about the part that you colored red, but I get the rest, and it stops at the same place, because a backslash in a command macro is a pause for User input only.  It doesn't care whether it's within a double-quoted text string, it doesn't function as a special-character trigger as it does in AutoLisp, and a command macro doesn't run AutoLisp functions [as Script can, at least some of them].


It's all contained within parenthesis, so it gets treated as a LISP function. I believe the intent was to use it in that manner, which if copied/pasted into a tools' command line, will work as it was penned.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 11 of 17

Kent1Cooper
Consultant
Consultant

@DGCSCAD wrote:.

It's all contained within parenthesis, so it gets treated as a LISP function. I believe the intent was to use it in that manner, which if copied/pasted into a tools' command line, will work as it was penned.


That's exactly what I did.  I copied @Sea-Haven 's code line in Message 6, and put it into the command macro content line in a Tool Palette button.  It did not work, but stopped at the first backslash, as already described.  Macros can contain AutoLisp functions [I have some using (setvar), for example], but I think do not recognize the backslash in the way AutoLisp uses it, but only as a pause for User input.  I haven't found a way in a command macro to get Mtext content to move down to a new line.

Kent Cooper, AIA
0 Likes
Message 12 of 17

DGCSCAD
Collaborator
Collaborator

Well, I'll be hornswaggled. I assumed (as one should never do) that they worked in the same manner. I don't use macro's, so my assumptions were incorrect (as usual lol).

A thousand pardons, good sir.

AutoCad 2018 (full)
Win 11 Pro
0 Likes
Message 13 of 17

Kent1Cooper
Consultant
Consultant

@Sea-Haven wrote:

Ok can see a few problems you have not defined the starting point for the MText should be before the "W"....


It is.  The first backslash is the pause for the User to pick the starting point.

Kent Cooper, AIA
0 Likes
Message 14 of 17

Kent1Cooper
Consultant
Consultant

WAIT!  A semi-colon [= Enter] is, in fact, the way to move down a line, but you can't do two in a row to get the empty line between your first two lines of content, because two Enters in a row ends the command.  But if you're willing to have a space as the empty line, this worked for me to make the arrangement in Message 5:

 

_.-Mtext \w 200 Materialisatie:; ;wit, Kronospan U566 SM;oranje, Unilin 0U272/BST Tiger;hout, Kronospan K004 PW;;

 

Kent Cooper, AIA
0 Likes
Message 15 of 17

gbG5A5W
Enthusiast
Enthusiast

That last code works. So thanx for this.

But I got confused by the remark of the double semi-colon. With a Dtext, a double semi-colon would end the command. In a Mtext, I can enter as much as I want, as far as I know?

0 Likes
Message 16 of 17

Kent1Cooper
Consultant
Consultant

@gbG5A5W wrote:

..... In a Mtext, I can enter as much as I want, as far as I know?


[You must have used the "Reply to the Topic..." slot below the last Message.  Don't do that -- it always shows as being in Reply to the author of Message 1.  Always use the "REPLY" or "QUICK REPLY" button toward the lower right in the Message you're actually Replying to.]

 

Manually, you can, but not within a command macro.  You can verify it easily enough -- try the macro content I posted but without the space between those two semicolons.  That's what I tried first, and the result is what made me say earlier that I hadn't found a way to move to a new line in macro-generated Mtext.  But later I found that a semicolon does work for that, but it needs some content, even if only a space, for each line.

Kent Cooper, AIA
0 Likes
Message 17 of 17

DGCSCAD
Collaborator
Collaborator

After finding out I don't know much about Macro's, I started looking into them and found some useful info:

 

Command Macro Strings 

Special Control Characters in Command Macros 

 

Posting here for others that may find it useful.

AutoCad 2018 (full)
Win 11 Pro
0 Likes