pline command in lisp routine

Discussion in 'AutoCAD' started by Jim Kleiner, Dec 2, 2004.

  1. Jim Kleiner

    Jim Kleiner Guest

    I am new to writing lisp and this is probably a simple problem but...

    I am trying to create a lisp routine that will insert a pline on a specific
    layer, with a specific linetype, and at a specific ltscale, the problem I am
    having is that when I right click to end the line it doesn't reset all of
    the variables I changed back to their original settings. ie ltscale, layer,
    linewidth.

    (defun C:Fence-L ()
    (setq svcl (getvar "clayer"))
    (setq svlts (getvar "celtscale"))
    (setq svlt (getvar "celtype"))
    (setq svplwdth (getvar "plinewid"))

    (setvar "cmdecho" 0)

    (setvar "clayer" "T-COVER")
    (setvar "celtype" "dash")
    (setvar "celtscale" 5)
    (setvar "plinewid" 0)

    (command "PLINE" PAUSE)

    (setvar "clayer" svcl)
    (setvar "celtscale" svlts)
    (setvar "cmdecho" 1)
    (setvar "plinewid" svplwdth)


    )

    Any suggestions

    Thanks
    Jim
     
    Jim Kleiner, Dec 2, 2004
    #1
  2. Look into the CMDACTIVE system variable, and the (while) operation. As long
    as the Polyline command isn't over yet (that is, a command is active --
    that's what CMDACTIVE stands for), you keep pausing for user input. Then
    when the polyline is done, it goes on to reset the settings. You can
    probably find examples of syntax, etc., by searching the newsgroup; gotta
    go.
     
    Kent Cooper, AIA, Dec 2, 2004
    #2
  3. Jim Kleiner

    Bill DeShawn Guest

    An example:
    (defun C:Fence-L ()
    (setq svcl (getvar "clayer"))
    (setq svlts (getvar "celtscale"))
    (setq svlt (getvar "celtype"))
    (setq svplwdth (getvar "plinewid"))

    (setvar "cmdecho" 0)

    (setvar "clayer" "T-COVER")
    (setvar "celtype" "dash")
    (setvar "celtscale" 5)
    (setvar "plinewid" 0)

    (command "PLINE" PAUSE)
    (while (= (getvar "cmdactive") 1) (command pause))
    ;while the above line hasn't failed me so far, the following line has
    been reported to be even better, yet.
    ; (while (> (getvar "cmdactive") 0) (command pause))
    (setvar "clayer" svcl)
    (setvar "celtscale" svlts)
    (setvar "cmdecho" 1)
    (setvar "plinewid" svplwdth)
    )

    Keep in touch
     
    Bill DeShawn, Dec 6, 2004
    #3
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.