finish lisp after enter

Discussion in 'AutoCAD' started by jclaidler, Apr 26, 2004.

  1. jclaidler

    jclaidler Guest

    I have a lisp routine for the dimcontinue command. When activated, the current layer will change to our DIM layer, then when done should go back to the original layer.

    Problem is, after the first dimension is placed, the next will be put on the original layer not the DIM layer.

    I need this to execute after the user hits enter:
    (setvar "CLAYER" oldlayer)

    Thanks.
     
    jclaidler, Apr 26, 2004
    #1
  2. Sounds like Enter is recalling the Dimcontinue, but obviously not the Layer
    setting part. Try "defun"-ing it all into a new "command" name, that has
    the Layer setting operations within it. Then when you recall it with Enter,
    you'll get that new command instead of the basic Dimcontinue command.

    Kent Cooper, AIA

    current layer will change to our DIM layer, then when done should go back to
    the original layer.
    the original layer not the DIM layer.
     
    Kent Cooper, AIA, Apr 26, 2004
    #2
  3. jclaidler

    jclaidler Guest

    Enter is not being used to RECALL it, but to 'end' the dimcontinue command. I need for the current layer to stay at DIM until they hit enter. Then go back to the original layer they were on.
     
    jclaidler, Apr 26, 2004
    #3
  4. That's beyond my abilities. I've done this: I have a Screen Menu for
    dimensioning, that has the stuff we actually use on it, and not all the rest
    that we normally don't. (The same could be done with a pull-down, or
    toolbar, or editing AutoCAD's toolbar, or....) When you pick the Screen
    Menu item that calls up that dimensioning Screen sub-Menu, it saves the
    current layer. (That part would be harder with a pull-down or toolbar --
    you'd probably have to build the layer setting into each item on them.)
    Then on the dimensioning menu, there's an "exit" item that sets the layer
    back where it was, and recalls the Main Screen Menu. It does require you to
    pick "exit" to reset the layer, but it allows you to do any and all kinds of
    dimensioning while you're set to the dimension layer.

    I can kind of imagine what your item might look like, with resetting the
    layer at the end, but leaving the dimcontinue command running, which would
    explain why subsequent dimensions go on the old layer. That approach works
    fine for dimensioning sub-commands that are one-shot, but I guess
    dimcontinue is a special case, because it may be the only one that repeats
    indefinitely, automatically.

    How about making a defun new command, with the layer setting and resetting
    things inside it, and with an ending Enter for dimcontinue, and then doing
    the
    *^C^C<your-dimcontinue-command>
    thing to make that new command repeat automatically? It would be switching
    layers back and forth with each dimension, but that shouldn't matter.

    Well, come to think of it, maybe that wouldn't work -- you'd have to set it
    up either:
    1) - to automatically choose to continue the latest dimension, in which case
    you could only use it when the particular dimension you want to continue is
    the latest one, or
    2) - to ask you which dimension you want to continue, in which case, when
    using it for more than one, you'd have to pick your last one repeatedly as
    you go.

    I'm all out of ideas....

    Kent Cooper, AIA
    command. I need for the current layer to stay at DIM until they hit enter.
    Then go back to the original layer they were on.
     
    Kent Cooper, AIA, Apr 26, 2004
    #4
  5. jclaidler

    jclaidler Guest

    Thanks... I have a 'defun' command. All my dimension programs work great, but this one. Because with dimcontinue, you are always in the command until you hit enter or right click.
     
    jclaidler, Apr 26, 2004
    #5
  6. jclaidler

    urugx Guest

    Why don't you post your lisp routine?
    Might be a lot easier to help if the way
    the routine was written is known.
     
    urugx, Apr 26, 2004
    #6
  7. There is a setvar "cmdactive" that can be used to allow users to pick until
    finished.
    Here is a portion of the code -

    (while (< 0 (getvar "cmdactive"))
    (princ "\nPick another or hit [ENTER] when finished.")
    (command pause)
    )
     
    Alan Henderson, Apr 26, 2004
    #7
  8. jclaidler

    bob.at Guest

    Hello,

    i've tried to solve your problem with a commandEnded reactor. I entered the following code in VLISP an loaded it:

    (vl-load-com)
    (setq mycommandreactor (vlr-command-reactor nil '(:)vlr-commandEnded . reset_layer))))
    (vlr-remove mycommandreactor)

    (defun C:mydim ()
    (setq oldlayer (getvar "CLAYER"))
    (setvar "CLAYER" "dimlayer")
    (if (vlr-added-p mycommandreactor)
    (vlr-add mycommandreactor)
    (setq mycommandreactor (vlr-command-reactor nil '(:)vlr-commandEnded . reset_layer))))
    )
    (command "_dimcontinue")
    )
    (defun reset_layer (a b)
    (setvar "CLAYER" oldlayer)
    (vlr-remove mycommandreactor)
    )

    The idea is: with "mydim" i change the layer and start a reactor, wich calls "reset_layer" and the removes the reactor.
    But this doesnt work at my AutoCAD 2004. The reactor is activ also after calling "reset_layer". So each command ends with the same call (also the layer command)!

    What is wrong with this short code?

    bob.at
     
    bob.at, Apr 26, 2004
    #8
  9. jclaidler

    jclaidler Guest

    Thanks... this works great.
     
    jclaidler, Apr 26, 2004
    #9
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.