Turn selected layer off and Turn all layers off except selected layer

 I've been using the slightly cumbersome command of LAYOFF to turn off a specific selected layer (without going into Layer properties), is there a more direct LISP routine or command to:

1. Turn selected layer off
2. Turn off all layers except selected layer


Comments

  • It's hard to imagine an easier way to turn off the layer of a selected object than the LAYOFF command, but to turn off all layers except the current one you can use a script that adds some parameters to the -LAYER command:
    -Layer/Off/*///   (a slash indicates an Enter or Space)
    I use MacroExpress to assign that sequence of keystrokes to a function key, but you can create a custom menu command that does the same thing. I don't know the syntax for menu scripts. In lisp, I think it would be:
    [code](defun c:XX () (command "-layer" "off" "*" "" "" ""))[/code]
  • I use these lisps to freeze and thaw an individual layer by selecting an entity.

    [code](Defun C:FLAYR ()
     (setq a (cdr (assoc 8 (entget (car (entsel))))))
     (print a)
    (IF (= a (GETVAR "CLAYER"))(COMMAND "-LA" "S" 0 ""))
    (command "-LA" "F" a "")
    )
    (Defun C:TLAYR ()
     (setq a (cdr (assoc 8 (entget (car (entsel))))))
     (print a)
    (command "-LA" "S" a "F" "*" "")
    )[/code]
  •  Thanks for the help with the commands, I'm still trying to learn how to code in my own.  I just worked out:

    To turn off all layers but a single specific one:
    ^C^C^P(COMMAND "-LAYER" "OFF" "*" "N" "-ENTER")^P

    1. Set the layer I want to stay on as the Current Layer
    2. Trigger keyboard shortcut
    3. The "N" keeps the Current Layer on (Y would turn off every layer)

    Anthony - As far as LAYOFF goes, went set as a keyboard shortcut it works perfectly to turn off a specific layer.

    Thanks again
  • 1. Do you know about LAYMCUR? It makes a selected object's layer the current layer. I have that assigned to a function key also. F9, pick an object, then F10 = turn off all layers except the one the selected object is on.

    2. Definitely keyboard shortcuts or aliases if you're going to use the command line. I use function keys instead of shift-key combinations, and single letter aliases for editing commands such as Copy and Move (C and M), and double letter aliases for drawing commands such as Line and Pline (LL and PP).

    3. I used Enter instead of N because No is the default answer.
  •  My Function Keys are filling up quickly:
    F1: Midpoint between two points
    F2: divide
    F3: unassigned
    F4: Dimension Edit

    I use three layer states: Architectural, Electrical, Structural
    F5: Turns on architectural layer state
    F6: Turns on electrical layer state
    F7: Turns on structural layer state

    F8: unassigned
    F9: Rotate object 90 degrees
    F10: Plot
    F11: Bring object to front
    F12: Send object to back

    Now I'm spilling unto my CTRL+number keys:
    CTRL+1: Make object current layer
    CTRL+2: Turn off all layers except current layer
    CTRL+3: LAYOFF
    CTRL+4: Match properties

    Not to mention my mouse with five programmable keys:
    Copy
    Move
    ECS
    Delete
    Enter


  • David, it's often more useful to freeze/thaw layers than turn off/on.
    I personally never use off/on.
    And you don't have to answer the question about the current layer - it just stays thawed.
  •  If you are running out of function keys, you can create a new icon and associate a macro to it,  I have one for turning off all layers, except for the current one.  my macro is 
    ^c^c-layer;off;*;;;

    I have a similar macro to turn all layers on, and another one that turns all on and thaws them as well.  Note that these sorts of macros can be more complex, but the most basic ones are just the keyboard commands.  Note that ; is used to indicate a return.

    -Joe
  • I have well over 200 routines, scripts etc including variations of those with typical inputs, which I use more or less often.
    Many need text descriptions to show what they do, or remember them by, but if they weren't on pull down menus I doubt I would find function keys or make icons for them.
  •  "Turn off all layers except selected layer"
    The LAYISO command does that, at least if you select the OFF option for the other layers (LAYISO locks the other layers by default).
This discussion has been closed.