Our survey department neets to add mtext that is justified middle center with a zero width. I have not used LISP resently and cannot figure out what I am missing.
(defun C:lbl ()
(command "-mtext" pause ; Activates mtext command
"Columns" "N" ; Removes columns
"Justify" "MC" ; Middle-center justified
"Width" "0" ; zero width
)
)
When I run this command I get this output at the command line:
Command: lbl -mtext Current text style: "SIMPLEX" Text height: 0.0600 Annotative: No Specify first corner: Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: Columns Enter column type [Dynamic/Static/No columns] <Dynamic>: No columns Invalid option keyword. ; error: Function cancelled
In testing out your code on the command line I have discovered (to my surprise!) that the MTEXT (actually -MTEXT) command options ([Height/Justify/Line spacing/Rotation/Style/Width/Columns]) apparently don't work at all. (I am running 2013.)
You might be able to set some (or all) of the settings outside the MTEXT command. For instance, the default column setting is stored in the MTEXTCOLUMN system variable. I can't find SysVars for the other two, but maybe someone else will chime in with methods for setting those ahead of the command (or modifying them after).
Thanks for the system varable. That helped with the script.
I found that setting the width and columns was causing problems. I removed the width and set the colums using the system varable.
Not what we wanted, but it works.
Hi,
Good to know that you have it working using the system variable which was suggested by dmfrazier.
I have tried the lisp code in AutoCAD 2012 and 2013 and it worked ok.
Can you try pasting the lisp statement directly in the AutoCAD command line window and see if it reports the same error message ?
(command "-mtext" pause "Columns" "N" "Justify" "MC" "Width" "0")
Also, can you provide the same inputs using the command line ? Does that work ?
Regards,
Balaji
When I enter the script into the command line I get the following:
Command: (command "-mtext" pause "Columns" "N" "Justify" "MC" "Width" "0") -mtext Current text style: "SIMPLEX" Text height: 3.6000 Annotative: Yes Specify first corner: Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: Columns Enter column type [Dynamic/Static/No columns] <Dynamic>: N Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: Justify Enter justification [TL/TC/TR/ML/MC/MR/BL/BC/BR] <TL>: MC Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: Width Specify width: 0 MText: nil
MText: *Cancel*
If I manually enter the information one step at a time it works:
Command: -MTEXT Current text style: "SIMPLEX" Text height: 3.6000 Annotative: Yes Specify first corner: Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: c Enter column type [Dynamic/Static/No columns] <Dynamic>: n Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: j Enter justification [TL/TC/TR/ML/MC/MR/BL/BC/BR] <TL>: mc Specify opposite corner or [Height/Justify/Line spacing/Rotation/Style/Width/Columns]: w Specify width: 0 MText: example
Your single line of LISP code does work for me in 2013 (though it is awkward as there are no prompts):
Command: (command "-mtext" pause "Columns" "N" "Justify" "MC" "Width" "0")
Current text style: "2thirds" Text height: 0.0938 Annotative: No
nil
MText: THIS IS MTEXT
MText: NEW LINE
MText:
Command:
Trying the OP's function again, today, it also works!
I'm not sure what's different today compared to my original test, but now even when I run -MTEXT on the command line I am able to get the various command options to respond.
Strange...
Just a hunch - I notice your text style is annotative. When you run on the command line, are you presented at any point with a prompt (dialog box) to select a scale?