User Prompts

Discussion in 'AutoCAD' started by Timothy Spangler, Jul 21, 2004.

  1. How do I go about continuing a command prompt until enter is selected? For
    instance if I want to use the line command but I want different prompts i.e.

    "Enter start point of conduit:"
    "Enter next point of conduit:"

    If I wanted to continue showing "Enter next point of conduit" until the user
    hit enter but still allowed for a line to be drawn how do I go about doing
    this? This is what I have now:

    (defun C:LINE_CONDUIT (/)

    ;; Error Handler
    (defun *error* (MSG)

    (if (not (member MSG '("console break" "Function cancelled" "quit / exit
    abort")))
    (progn
    (princ "\n\n...An Error was encountered...\n ")
    (princ (strcat "\nThe following error was detected: " (strcase MSG)))
    )
    (princ "\n\n...Program Ended... ")
    )
    (while (< 0 (getvar "cmdactive"))
    (command)
    )
    (setvar "cmdecho" OldCmdEcho)
    )
    (setq OldCmdEcho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq StartPoint (getpoint "\nSelect Stating Point of Conduit:"))
    (setq NextPoint (getpoint "\nSelect Next Point of Conuit:"))
    (command "line" StartPoint NextPoint "")
    (while (= 0 (getvar "cmdactive"))
    (setq StartPoint NextPoint)
    (setq NextPoint (getpoint "\nSelect Next Point of Conuit:"))
    (command "line" StartPoint NextPoint "")
    )
    (princ)
    )

    Everything works except in order to end the user must hit ESC.

    Thanks

    Timothy Spangler
     
    Timothy Spangler, Jul 21, 2004
    #1
  2. Timothy Spangler

    ECCAD Guest

    Change:
    (while (= 0 (getvar "cmdactive"))
    To:
    (while (> 0 (getvar "cmdactive"))

    Bob
     
    ECCAD, Jul 21, 2004
    #2
  3. Timothy Spangler

    MP Guest

    first off, localize *error* if you define one like that
    (defun C:LINE_CONDUIT (/ *error*)
    ....snip...

    (setq StartPoint (getpoint "\nSelect Stating Point of Conduit:"))
    (command "Line" Startpoint)

    (while (< 0 (getvar "cmdactive"))
    (prompt "Enter next point of conduit:")

    (command pause)
    )
    (command)
    (princ"\nDone with that one! :) ")

    )

    or something like that?
     
    MP, Jul 21, 2004
    #3
  4. Timothy Spangler

    ECCAD Guest

    MP,
    I figured he would study the while loop and reason that
    within the loop - if you crank up a command, will never exit..
    But, then you posted.
    Bye the way, you need a > not a <.

    Bob
     
    ECCAD, Jul 21, 2004
    #4
  5. Timothy Spangler

    ECCAD Guest

    A little tougher than I thought. This works..
    (defun C:LINE_CONDUIT ( / *error* )

    ;; Error Handler
    (defun *error* (MSG)

    (if (not (member MSG '("console break" "Function cancelled" "quit / exit abort")))
    (progn
    (princ "\n\n...An Error was encountered...\n ")
    (princ (strcat "\nThe following error was detected: " (strcase MSG)))
    )
    (princ "\n\n...Program Ended... ")
    );if
    (setvar "cmdecho" OldCmdEcho)
    );function

    ;; Begin program

    (setq OldCmdEcho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq StartPoint (getpoint "\nSelect Stating Point of Conduit:"))
    (setq NextPoint (getpoint StartPoint "\nSelect Next Point of Conuit:"))
    (command "line" StartPoint NextPoint "")
    (setq StartPoint NextPoint)
    (setq NextPoint (getpoint "\nSelect Next Point of Conuit:"))
    (while NextPoint
    (command "line" StartPoint NextPoint "")
    (setq StartPoint NextPoint)
    (setq NextPoint (getpoint StartPoint "\nSelect Next Point of Conuit:"))
    )
    (princ)
    (princ"\nDone with that one! :) ")

    (princ)
    ); function

    Bob
     
    ECCAD, Jul 21, 2004
    #5
  6. Timothy Spangler

    MP Guest

    nope, i don't think so - the snip i posted tested correctly

    (< 0 (Getvar"cmdactive"))
    0 is less than 1
    :)
    or if you prefer > then
    (while(>(Getvar"Cmdactive")0)
    or could just be
    (while(/= (Getvar"Cmdactive")0)

    or maybe i'm just more confused than normal today
    :)
     
    MP, Jul 21, 2004
    #6
  7. Timothy Spangler

    ECCAD Guest

    No,
    You moved the 0.. :)
    good one.
    I'm the one confused.
    But, see my last post..is tricky.

    Bob
     
    ECCAD, Jul 21, 2004
    #7
  8. Timothy Spangler

    MP Guest

    no better, but just a little shorter, and might as well show good form by
    localizing all the vars
    actually good form would avoid use of command at all
    rather write a function to draw a line, then use your method of getting
    points, and pass them to function
    but since the thread started with the command method, that's what i followed

    (defun C:LINE_CONDUIT2 ( / *error* OldCmdEcho prmpt Startpoint)
    ;; Error Handler
    (defun *error* (MSG)
    (if (not (member MSG '("console break" "Function cancelled" "quit / exit
    abort")))
    (progn
    (princ "\n\n...An Error was encountered...\n ")
    (princ (strcat "\nThe following error was detected: " (strcase MSG)))
    )
    (princ "\n\n...Program Ended... ")
    );if
    (setvar "cmdecho" OldCmdEcho)
    );function
    ;; Begin program
    (setq OldCmdEcho (getvar "cmdecho"))
    (setvar "cmdecho" 0)
    (setq StartPoint (getpoint "\nSelect Stating Point of Conduit:"))
    (command "Line" Startpoint)
    (setq prmpt"\nSelect Next Point of Conduit:")
    (while(< 0 (Getvar"Cmdactive"))
    (prompt prmpt)
    (command pause)
    )
    (princ"\nDone with that one! :) ")
    (princ)
    ); function
     
    MP, Jul 21, 2004
    #8
  9. Thanks guys I appreciate the help.

    Timothy Spangler
     
    Timothy Spangler, Jul 22, 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.