command line macros in mns files - how to do

Discussion in 'AutoCAD' started by Dave R., Jan 11, 2005.

  1. Dave R.

    Dave R. Guest

    Can I put simple command line macros in a custom MNS file so they are
    portable? If so what is the syntax?

    For example if I wanted to map a command "str" to ^C^C^CSTRETCH;CP;


    Thanks,

    Dave R.
     
    Dave R., Jan 11, 2005
    #1
  2. Dave R.

    j buzbee Guest

    How about in an ACADDOC.lsp file in the search path? It'll get loaded in
    each drawing. Syntax could simply be:

    (defun c:str( / )
    (command "_.stretch cp ")(princ))

    Note the spaces between stretch and cp.

    jb
     
    j buzbee, Jan 11, 2005
    #2
  3. Dave R.

    Dave R. Guest

    I would prefer the portability of an MNS if possible. For me it lessens the
    impact of version upgrades and creating a mirror of my work setup at home.

    - Dave R.
     
    Dave R., Jan 11, 2005
    #3
  4. Dave R.

    Dave R. Guest

    jb,

    I loaded your lisp macro into my acad2004doc.lsp but I get the following
    error while trying to use it:

    Command: str
    _.stretch cp Unknown command "STRETCH CP ". Press F1 for help.

    It doesn't look like it is executing the command then the subcommand
    sequentially but both at the same time. I know nothing about lisp syntax so
    I'm lost...

    - Dave R.
     
    Dave R., Jan 11, 2005
    #4
  5. Dave R.

    ecable Guest

    Create your own menu and load that. Then create yourmenu.mnl to load your stuff. Use jb's example in yourmenu.mnl.
     
    ecable, Jan 11, 2005
    #5
  6. Dave R.

    ecable Guest

    (defun c:str( / )
    (command "_.stretch" "cp")(princ))
     
    ecable, Jan 11, 2005
    #6
  7. Dave R.

    Tom Smith Guest

    I loaded your lisp macro into my acad2004doc.lsp but ...

    Dave, several points.

    It's recommended that you don't modify the supplied acad2004doc.lsp. If
    you're going to do this, create your own acaddoc.lsp as per the suggestion.

    The syntax suggested doesn't work. It should be:

    (defun c:str( / )
    (command "_.stretch" "cp")
    (princ)
    )

    The indentation doesn't matter, but note the use of quotation marks for each
    separate string. You want to quote separately each thing that you would
    enter at the command prompt. Without getting deeply into lisp, you can use
    this as a template for other keyboard macros, such as:

    (defun c:ze( / )
    (command "_.zoom" "e")
    (princ)
    )

    Finally, a good measure for portability might be to put such things in an
    MNL file of the same base name as your MNS. The MNL will load automatically
    when the menu loads. MNL's are intended to hold any lisps which are used by
    the MNS file, but because of their automatic loading they can be used for
    the same type things as the acaddoc.lsp file.
     
    Tom Smith, Jan 11, 2005
    #7
  8. Dave R.

    j buzbee Guest

    yea yea yea - what he said
     
    j buzbee, Jan 11, 2005
    #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.