help with this lisp routine

Discussion in 'AutoCAD' started by chetz, Oct 6, 2004.

  1. chetz

    chetz Guest

    I have this lisp routine that toggles a layer on and off. what I would like to do is use it to toggle on and off all layers beginning with...I tried putting an asterik after the layer name but that didnt work...any help would be appreciated.
    I realize you can do this easily with the command line -layer command but our company uses this in a toolbar as a toggle...

    (defun C:LXTOPO (/ ldat clr)
    (setq ldat (entget (tblobjname "layer" "topo"))
    clr (- (cdr (assoc 62 ldat)))
    )
    (entmod (subst (cons 62 clr)(assoc 62 ldat) ldat))
    (princ)
    )
     
    chetz, Oct 6, 2004
    #1
  2. chetz

    James Allen Guest

    This should do it.
    --
    James Allen
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO

    (defun C:LXTOPO (/ ldat clr)
    (setq ldat (tblnext "layer" t))
    (while (setq ldat (tblnext "layer"))
    (setq ldat (cdr (assoc 2 ldat)))
    (if (wcmatch ldat "topo*")
    (progn
    (setq ldat (entget (tblobjname "layer" ldat))
    clr (- (cdr (assoc 62 ldat)))
    )
    (entmod (subst (cons 62 clr) (assoc 62 ldat) ldat))
    )
    )
    )
    (princ)
    )
     
    James Allen, Oct 6, 2004
    #2
  3. chetz

    chetz Guest

    hmm....
    This isn't working for me. Doesn't do anything to any layer.
     
    chetz, Oct 11, 2004
    #3
  4. chetz

    James Allen Guest

    Sorry. Change (wcmatch ldat "topo*") to (wcmatch (strcase ldat t) "topo*").
    This will toggle the current on/off state of every layer that starts with
    "topo".
     
    James Allen, Oct 11, 2004
    #4
  5. chetz

    chetz Guest

    great. that did the trick ! Thanks.
     
    chetz, Oct 11, 2004
    #5
  6. chetz

    James Allen Guest

    You're welcome.
     
    James Allen, Oct 12, 2004
    #6
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.