tablesearch layerstates

Discussion in 'AutoCAD' started by jlspartz, Jan 14, 2005.

  1. jlspartz

    jlspartz Guest

    Is it possible to do a tablesearch on layerstates? This is what I have written. Why does this not work? How do I change it?

    (defun c:savels-ao ()
    (setvar "cmdecho" 0)
    (command "undo" "end")
    (command "undo" "group")
    (setq lay(getvar "clayer"))
    (setvar "clayer" "0")
    (if (tblsearch "ACAD_LAYERSTATES" "ALL_ON"))
    (command "-layer" "state" "delete" "ALL_ON" "" ""))
    (command "-layer" "state" "save" "ALL_ON" "" "" "")
    (setvar "clayer" lay)
    (command "undo" "end")
    (setvar "cmdecho" 1)
    (princ "\n\n*** Layer State ALL_ON Saved *** \n\n")
    (princ)
    )
     
    jlspartz, Jan 14, 2005
    #1
  2. jlspartz

    Tom Smith Guest

    Is it possible to do a tablesearch on layerstates? This is what I have
    written. Why does this not work? How do I change it?

    No, they're not in a table. I think they're in a dictionary? You could
    search this NG, I think it's been mentioned before.

    Why are you doing an undo end at the beginning?

    Looks like you're trying to save an "all on" layer state in the drawing,
    which you can't do if the named state already exists. Instead of trying to
    check for the state, just try to delete it in all cases -- the only
    difference is the layer command takes an extra return if the state isn't
    there.

    (command "-layer" "state" "delete" "all_on" "" "") ;delete it
    (if (zerop (getvar "cmdactive")) ;it got deleted
    (princ)
    (command "")) ;extra return if lstate wasn't found
    (command "-layer" "state" "save" "all_on" "" "" "") ;save it

    BTW, how are you creating the condition before you save it? Seems like you'd
    want to have a "layer on *" in there before this.
     
    Tom Smith, Jan 14, 2005
    #2
  3. jlspartz

    jlspartz Guest

    Thanks Tom, I was wondering if I could do that extra enter at the end if the state didn't exist, so to work around that I was trying a tablesearch to see if it existed before performing the command. But, this is what I really wanted.

    The undo end at the beginning is making sure that there isn't an undo still going on from some other command, for safety purposes, it doesn't hurt to put it in.

    No, I don't want to set the layer conditions for this. I have an all on command also. This is just one of our standard states that the user will set the layers for, because what they want to see when hitting the all on state isn't everything that is in the drawing.
     
    jlspartz, Jan 14, 2005
    #3
  4. jlspartz

    Tom Smith Guest

    Thanks Tom, I was wondering if I could do that extra enter at the end if
    the state didn't exist

    You're welcome. That trick sometimes comes in handy. You can also use the
    cmdactive test in cases where you don't know how long a user might stay
    inside a command function, for instance, picking variable number of points
    for a polyline.
     
    Tom Smith, Jan 14, 2005
    #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.
Similar Threads
Loading...