make object layer current

Discussion in 'AutoCAD' started by AMKELLY, Jan 13, 2005.

  1. AMKELLY

    AMKELLY Guest

    II am trying to write a keyboard shortcut "cl" (for current layer) that will invoke the command "_ai_molc" so I don't have to type it or use the menus. This is what I wrote:

    (defun c:cl () (command "_ai_molc"))

    but autocad says that "ai_molc" is an unknown command, probably because it has dropped off the first underscore "_"

    what am I doing wrong?
     
    AMKELLY, Jan 13, 2005
    #1
  2. AMKELLY

    Josh Guest

    (defun c:cl ()(c:ai_molc)(princ))

    will invoke the command "_ai_molc" so I don't have to type it or use the
    has dropped off the first underscore "_"
     
    Josh, Jan 13, 2005
    #2
  3. AMKELLY

    Tom Smith Guest

    (defun c:cl () (command "_ai_molc"))
    has dropped off the first underscore "_"

    No, the command is unknown because it isn't a native Acad command. It's a
    lisp function, so it needs to be called as Josh demonstrated.
     
    Tom Smith, Jan 13, 2005
    #3
  4. If you don't want to type it (including not wanting to type the "cl"), you
    don't need to defun anything if you can have the keyboard shortcut invoke
    something like

    '-LAYER S (cdr (assoc 8 (entget (car (entsel))))) \;

    This also has the definite advantage that it can be done transparently in
    mid-command, whereas _ai_molc cancels any command you're in (at least when
    you pick the icon for it in the Layer toolbar).
     
    Kent Cooper, AIA, Jan 13, 2005
    #4
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.