Check if a command is undefined

Discussion in 'AutoCAD' started by Alan Henderson @ A'cad Solutions, Jun 9, 2004.

  1. I've written a startup ACADDOC.lsp that undefines MTEXT.
    When I start AutoCAD 2002 I get an error "Unknown command name." when (command "UNDEFINE" "MTEXT") runs in the startup routine.
    I checked to make sure that is the offending line in the file.
    I am also undefining the TEXT and DTEXT command and I am not having a problem with undefining these commands.

    If I create a new drawing or open an existing drawing after the first error, I get the same error.
    If I then use (command "UNDEFINE" "MTEXT") or issue the Undefine command from command prompt, for any new or existing drawing in the current session, the startup program works properly.

    I'm wondering if I should check to make sure the command is all ready undefined.

    Is there a method using Lisp or VLA functions to see if a command is undefined?
    Or has anyone else run into this problem.
     
    Alan Henderson @ A'cad Solutions, Jun 9, 2004
    #1
  2. Alan Henderson @ A'cad Solutions

    Jeff Mishler Guest

    I believe that Mtext is NOT an internal Acad command, but rather an
    externally loaded ARX application and is not loaded until it is needed,
    which why it can't be undefined.

    Jeff

    message I've written a startup ACADDOC.lsp that undefines MTEXT.
    When I start AutoCAD 2002 I get an error "Unknown command name." when
    (command "UNDEFINE" "MTEXT") runs in the startup routine.
    I checked to make sure that is the offending line in the file.
    I am also undefining the TEXT and DTEXT command and I am not having a
    problem with undefining these commands.

    If I create a new drawing or open an existing drawing after the first error,
    I get the same error.
    If I then use (command "UNDEFINE" "MTEXT") or issue the Undefine command
    from command prompt, for any new or existing drawing in the current session,
    the startup program works properly.

    I'm wondering if I should check to make sure the command is all ready
    undefined.

    Is there a method using Lisp or VLA functions to see if a command is
    undefined?
    Or has anyone else run into this problem.
     
    Jeff Mishler, Jun 9, 2004
    #2
  3. Alan Henderson @ A'cad Solutions

    Paul Turvill Guest

    Huh?

    Command: MTEXT
    Current text style: DIMS. Text height: 4 1/2"
    Specify first corner: *Cancel*

    Command: UNDEFINE Command name: *Cancel*

    Command: MTEXT
    Current text style: DIMS. Text height: 4 1/2"
    Specify first corner: *Cancel*

    Command: UNDEFINE
    Command name: MTEXT

    Command: MTEXT
    Unknown command "MTEXT". Press F1 for help.
    ___

    Enter Insert key to select menu item.
     
    Paul Turvill, Jun 10, 2004
    #3
  4. Alan Henderson @ A'cad Solutions

    Paul Turvill Guest

    Oops ... posted more than I intended:

    Command: MTEXT
    Current text style: DIMS. Text height: 4 1/2"
    Specify first corner: *Cancel*

    Command: UNDEFINE
    Command name: MTEXT

    Command: MTEXT
    Unknown command "MTEXT". Press F1 for help.


    At any rate, the MTEXT command *can* be undefined.
     
    Paul Turvill, Jun 10, 2004
    #4
  5. Alan Henderson @ A'cad Solutions

    Jeff Mishler Guest

    Starting a new drawing....

    Regenerating model.

    Initializing....
    ..Done.
    Initializing VBA System...
    Loading VBA startup file...
    AutoCAD Express Tools Copyright © 2000 Autodesk, Inc.
    undefine Enter command name: plot
    AutoCAD menu utilities loaded.
    Command: undefine
    Enter command name: mtext

    Unknown command name.

    Command:

    OK Do something that uses the mtext editor....

    Command: mtext ;;;;;;;;HERE IT TAKES A MOMENT TO LOAD
    Current text style: "Standard" Text height: 0.2000
    Specify first corner:
    Specify opposite corner or [Height/Justify/Line
    spacing/Rotation/Style/Width]:

    Command: undefine
    Enter command name: mtext

    Command: mtext
    Unknown command "MTEXT". Press F1 for help.

    My point was, the arx is not loaded until the command is used. Once used the
    command interpreter knows it is a command so THEN it can be
    undefined....whew! Since the acad.lsp is loaded prior to a call to the mtext
    command, trying to undefine it there fails.

    Jeff
     
    Jeff Mishler, Jun 10, 2004
    #5
  6. Thanks Jeff!!! That solves my problem. I just need to use mtext then I can
    undefine it.

    FYI, that is curious, that mtext is not a member of AutoCAD base commands.
    Maybe it's not a "finished" command???
     
    Alan Henderson @ A'cad Solutions, Jun 10, 2004
    #6
  7. MTEXT is an externally defined command. Its implementation
    is demand loaded, so at the start of the editing session,
    it will not be recognized as a command until the first time
    it is issued.

    For externally defined commands, you don't have to UNDEFINE
    them to replace them with LISP, if the command hasn't been
    invoked yet.

    The following is the general pattern for replacing either
    a built-in or externally defined, demand-loaded command:

    (if (getcname "MTEXT")
    (command "._UNDEFINE" "MTEXT")
    )

    (defun C:MTEXT ()
    (princ "\nHere is the replacement command for MTEXT")
    (princ)
    )

    If you run the above at startup, you'll see that the
    replacement command is used when you issue MTEXT at
    the command line, even if the MTEXT command was not
    undefined.


    --
    http://www.caddzone.com

    AutoCAD based Security Planning Solutions:
    http://www.caddzone.com/securityplanning

    AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005
    http://www.acadxtabs.com
     
    Tony Tanzillo, Jun 10, 2004
    #7
  8. Alan Henderson @ A'cad Solutions

    Doug Broad Guest

    Alan,
    You could also do this
    (arxload "acmted")
    (command "undefine" "mtext")
     
    Doug Broad, Jun 10, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.