Layer Automation - current layer

Discussion in 'AutoCAD' started by Jawknee99, Oct 13, 2004.

  1. Jawknee99

    Jawknee99 Guest

    I have searched and not found exactly what I need to do which is;

    1 - Get the current layer

    2 - Run the following code that is in a separate lisp file (A-LAYERNAME will
    vary eg: A-TEXT, A-DIM etc.)

    (defun c:A-LAYERNAME ()
    (setq layername "A-LAYERNAME")
    (command "-layer" "thaw" layername "make" layername "color" 3
    layername "ltype" "continuous"
    layername "lweight" "default" layername
    "" )
    (princ)
    )

    3 - Run a command which will also vary (eg: text, dimlinear etc.)

    4 - Reset to the current layer when step 3 is complete.

    I have used steps 2 and 3 above for years and it works very well. I put
    A-LAYERNAME ahead of a command in a menu or button eg: "A-TEXT;DTEXT;" or
    "A-DIM;DIMLINEAR;".

    I would like to improve it by adding steps 1 and 4. Maybe somehow using the
    cmdactive variable? I don't know, I am not a lisper. Maybe someone could
    point me down the right road.

    Much thanks to all in advance.

    -Storm
     
    Jawknee99, Oct 13, 2004
    #1
  2. Jawknee99

    T.Willey Guest

    If what you are asking is getting the current layer, then running your code, then setting it back. It would be:

    step 1
    (setq clay (getvar "clayer"))

    step 2 & 3

    step 4
    (setvar "clayer" clay)

    Hope that helps.
    Tim
     
    T.Willey, Oct 13, 2004
    #2
  3. Jawknee99

    Jawknee99 Guest

    Thanks.

    (setq clay (getvar "clayer")) works great and runs fine before step 2 and 3.
    The problem is running (setvar "clayer" clay) AFTER the regular AutoCAD
    command in step 3 is complete. How can I tell AutoCAD - "okay the command
    is complete now run (setvar "clayer" clay)"?

    Step 2 is one of about 30 defuns in a lisp file and step 3 is a standard
    AutoCAD command that is called from my button macro not the lisp file. Does
    this make sense?

    -Storm


    The first part isn't a problem with the code you provided but the
    code, then setting it back. It would be:
     
    Jawknee99, Oct 14, 2004
    #3
  4. Jawknee99

    T.Willey Guest

    Storm,

    I'm not that good with menu macros, and it seems to me that is what you want. But I tried this in acad and it seemed to work by pushing the button.

    ^C^C(setq clay (getvar "clayer"));(c:pua);regen;(setvar "clayer" clay);

    Where the (c:pua) represents my lisp file to run.

    Hope that helped.
    Tim
     
    T.Willey, Oct 14, 2004
    #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.