Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LISP Error, need help

6 REPLIES 6
Reply
Message 1 of 7
wsargent
737 Views, 6 Replies

LISP Error, need help

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

 

__________

AutoCAD Civil 3D 2016 SP3.0, built on: AutoCAD 2016 SP1, Map 3D 2016 SP2
Dell Percision T5810: MS Windows 10 Pro; Intel Xeon CPU E5-1620 v3 @ 3.50 GHz, 16.00 GB RAM, NVIDIA K2200 4.00 GB Memory
Tags (1)
6 REPLIES 6
Message 2 of 7
dmfrazier
in reply to: wsargent

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).

Message 3 of 7
wsargent
in reply to: wsargent

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.

__________

AutoCAD Civil 3D 2016 SP3.0, built on: AutoCAD 2016 SP1, Map 3D 2016 SP2
Dell Percision T5810: MS Windows 10 Pro; Intel Xeon CPU E5-1620 v3 @ 3.50 GHz, 16.00 GB RAM, NVIDIA K2200 4.00 GB Memory
Message 4 of 7
Balaji_Ram
in reply to: wsargent

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

 



Balaji
Developer Technical Services
Autodesk Developer Network

Message 5 of 7
wsargent
in reply to: Balaji_Ram

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

 

__________

AutoCAD Civil 3D 2016 SP3.0, built on: AutoCAD 2016 SP1, Map 3D 2016 SP2
Dell Percision T5810: MS Windows 10 Pro; Intel Xeon CPU E5-1620 v3 @ 3.50 GHz, 16.00 GB RAM, NVIDIA K2200 4.00 GB Memory
Message 6 of 7
dmfrazier
in reply to: Balaji_Ram

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...

 

 

 

Message 7 of 7
dmfrazier
in reply to: wsargent

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?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost