Turning off Layers

Discussion in 'AutoCAD' started by Scott, Dec 19, 2003.

  1. Scott

    Scott Guest

    Hi,

    I was wondering, how do I turn off all the layers in the active drawing
    using lisp?

    TIA

    Scott
     
    Scott, Dec 19, 2003
    #1
  2. Scott

    Rudy Tovar Guest

    (command "layer" "off" "*" "" "")

    Just remember to reset the current layer to "0" or whatever.
    --

    AUTODESK
    Authorized Developer
    www.Cadentity.com
    MASi
     
    Rudy Tovar, Dec 19, 2003
    #2
  3. Scott

    Jeff Mishler Guest

    And here's pure lisp that will not prompt about turning off the current
    layer. It's actually a toggle type,
    type in "alloff" to turn 'em off, "allon" to turn 'em back on.

    Jeff

    (defun onoffall (onoff /)
    (vl-load-com)
    (vlax-for lay
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (if (= onoff "on")
    (vla-put-layeron lay :vlax-true)
    (vla-put-layeron lay :vlax-false)
    )
    )
    )
    (defun c:allon ()
    (onoffall "on")
    (princ)
    )
    (defun c:alloff ()
    (onoffall nil)
    (princ)
    )
     
    Jeff Mishler, Dec 19, 2003
    #3
  4. Scott

    John Uhden Guest

    Don't know what you're up to , but one way is ...
    (command "_.layer" "_Off" "*" "")
     
    John Uhden, Dec 20, 2003
    #4
  5. Here is one with a prompt:

    (DEFUN C:LRF ()
    (Setvar "Cmdecho" 0)
    (Setq A (Entsel "\Touch entity to freeze: "))
    (If A (Progn (Setq A (Cdr (Assoc 8 (Entget (Car A)))))))
    (Command "LAYER" "FREEZE" A "")
    (Princ)
    (PROMPT "LAYER FROZEN: ")(EVAL A)
    )
     
    Kevin R. Knox, Dec 20, 2003
    #5
  6. Scott

    Jeff Mishler Guest

    And here's a different variation.
    allon - turns all layers on
    alloff - turns all layers off
    allbut - turn all layersoff except the current layer


    (defun onoffall (onoff /)
    (vl-load-com)
    (vlax-for lay
    (vla-get-layers
    (vla-get-activedocument
    (vlax-get-acad-object)))
    (cond ((= onoff "on")(vla-put-layeron lay :vlax-true))
    (onoff (if (= (vla-get-name lay)(getvar "clayer"))
    (vla-put-layeron lay :vlax-true)
    (vla-put-layeron lay :vlax-false)))
    (t (vla-put-layeron lay :vlax-false))
    )
    )
    )
    (defun c:allon ()
    (onoffall "on")
    (princ)
    )
    (defun c:alloff ()
    (onoffall nil)
    (princ)
    )
    (defun c:allbut()
    (onoffall t)
    (princ)
    )
     
    Jeff Mishler, Dec 20, 2003
    #6
  7. Scott

    Scott Guest

    Hi,

    I am using a lisp routine to draw a symbol representing the end of a pipe,
    the one that looks like a ying yang without the two dots at the top and
    bottom. I want to turn all the layers off so that my hatching on the right
    hand side of the symbol is not "cut off" by other entities in the drawing
    like the centerlines for the pipe.

    Thank you all for helping me out with this, this is exactly what I need!

    Scott
     
    Scott, Dec 22, 2003
    #7
  8. Scott

    BTO Guest

    I was wondering, how do I turn off all the layers in the active drawing
    hi,

    using lisp : you need to change color number for each layer throught layer
    table.
    when a color is negative : layer is off.

    Bruno Toniutti
     
    BTO, Jan 7, 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.