Lisp in toolbar command for toggling a layer state?

Discussion in 'AutoCAD' started by Nathan Kendall, Mar 1, 2005.

  1. Hello,

    I'm pretty green when it comes to lisp, even though I've been using AutoCAD
    for 8 years. It's something I've always wanted to learn but I have never
    taken the time.

    One thing I would love to find out is how to write a simple toolbar command
    lisp expression to toggle the state of a layer with a fixed name (for
    example "Viewports" which appears in nearly every single drawing). Right
    now I have 2 buttons, one that turns it on, and the other off. This is OK,
    however now I'm faced with a huge project in which there are several x-ref
    layers over multiple drawings that I'd love to be able to turn on and off,
    without creating 2 buttons for each one.

    Does this make sense? I think it's something about querying the layer state
    and turning on or off with what the query returns, but I'm not sure how to
    write that in lisp. I have some javascript and C++ exprience, so the logic
    is simple, but the syntax is beyond me, and searching through the help
    didn't help me (pun intended).

    Thanks for any help,
    Nathan
     
    Nathan Kendall, Mar 1, 2005
    #1
  2. Hmm... ok, well, can someone just shed some light on how I would query a
    layer's state using autolisp? I can probably figure out how to get the if
    statement working, and controlling the layer's state is easy.

    Thanks in advance,
    Nathan
     
    Nathan Kendall, Mar 3, 2005
    #2
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.