PDA

View Full Version : Polyline Pause


fletch97
2006-02-24, 07:43 PM
Morning or Afternoon....depending on where you are in the world.

Stupid question....

Try to write a lisp routine where I want the user to draw using the PL command and continue running the lisp once they have completed their polyline. My problem is...how do I do that? I tried using "pause" which works but is limited to how many I enter into the lisp. I want to give the user the ability to draw the polyline as long as they want and once the hit the enter key or close the polyline....the rest of the lisp routine kicks in.

Any help is much appreciated!

.T.
2006-02-24, 08:00 PM
How about something like this? (command "_pline" (getpoint "\nFirst point: "));execute pline command
(while (> (getvar "cmdactive") 0)
(princ "\nNext Point: ")
(command pause)
);end while
;;rest of code here

Opie
2006-02-24, 08:35 PM
How about something like this? (command "_pline" (getpoint "\nFirst point: "));execute pline command
(while (> (getvar "cmdactive") 0)
(princ "\nNext Point: ")
(command pause)
);end while
;;rest of code here
Have you tested this?

I have run into this exact same problem. I would like to be able to create a polyline including the options associated with creating a polyline from the command prompt. The while loop for cmdactive doesn't seem to function properly with the polyline command.

.T.
2006-02-24, 08:45 PM
Hi Opie,

Yes, I tested it, and it works fine.

(defun c:pltest ()
(command "_pline" (getpoint "nFirst point: "));execute pline command
(while (> (getvar "cmdactive") 0)
(princ "nNext Point: ")
(command pause)
);end while
)

But, I was contemplating the prompt portion of the snippet. Close, arc, etc. seems to work fine, but I didn't put in anything to tell the user what is going on.

I probably need to look at the "stock" command prompt and modify accordingly, including the current width prompt. I'll get back to you.

Thanks,

Opie
2006-02-24, 08:51 PM
Hi Opie,

Yes, I tested it, and it works fine.

(defun c:pltest ()
(command "_pline" (getpoint "nFirst point: "));execute pline command
(while (> (getvar "cmdactive") 0)
(princ "nNext Point: ")
(command pause)
);end while
)

But, I was contemplating the prompt portion of the snippet. Close, arc, etc. seems to work fine, but I didn't put in anything to tell the user what is going on.

I probably need to look at the "stock" command prompt and modify accordingly, including the current width prompt. I'll get back to you.

Thanks,
Thanks, Tim. I do not have the time right now to test it.

T.Willey
2006-02-24, 08:52 PM
When I have done this, I have turned on cmdecho (setvar "cmdecho" 1) so that the user could see what they could do. Just an idea.

.T.
2006-02-24, 09:05 PM
No, wait a minute.

I see what you are saying. Maybe this won't work if the user needs anything besides the "basic" polyline command. Upon further testing, it seems that the width prompt causes problems (I have to enter "w" twice, etc.).

Yes, Tim, I see your point: why mess with it when it'll take care of itself.

Lesson learned,

OK, how about this: (which is probably posted elsewhere):Oops: .


(defun c:pltest ()
(setvar "cmdecho" 1)
(command "_pline" pause)
(while (> (getvar "cmdactive") 0)
(command pause)
);end while
)

Opie
2006-02-24, 09:16 PM
Now I have to figure out why my attempt wasn't working. ~shrug~ Oh well. Thanks, Tim.

fletch97
2006-02-24, 10:45 PM
Thanks guys....the Poyline part of the lisp works great but I can't figure out why my lisp won't work. Take a look and let me know what I may have done wrong?

(defun c:Cloud ()
(setvar "cmdecho" 1)
(setq TM (getvar "tilemode"))
(if (= TM "1")
(progn
(REVMS)
)
)
(if (= TM "0")
(progn
(REVPS)
)
)
(setvar "cmdecho" 1)
(princ)
)


(defun REVMS ()
(setvar "cmdecho" 1)
(command "_pline" pause)
(while (> (getvar "cmdactive") 0)
(command pause)
)
(setvar "cmdecho" 0)
(command "revcloud" "A" "2'" "" "O" "Last" "")
(setvar "cmdecho" 1)
(princ)
)

(defun REVPS ()
(setvar "cmdecho" 1)
(command "_pline" pause)
(while (> (getvar "cmdactive") 0)
(command pause)
)
(setvar "cmdecho" 0)
(command "revcloud" "A" "1/8" "" "O" "Last" "")
(setvar "cmdecho" 1)
(princ)

T.Willey
2006-02-24, 10:51 PM
You have to compare two like things. (getvar "tilemode") returns and integer, not a string, so your test should be like this

(defun c:Cloud ()
(setvar "cmdecho" 1)
(setq TM (getvar "tilemode"))
(if (= TM 1)
(progn
(REVMS)
)
)
(if (= TM 0)
(progn
(REVPS)
)
)
(setvar "cmdecho" 1)
(princ)
)

And since you only have two options, you could write it like

(defun c:Cloud ()
(setvar "cmdecho" 1)
(setq TM (getvar "tilemode"))
(if (= TM 1)
(REVMS)
(REVPS)
)
(setvar "cmdecho" 1)
(princ)
)

Also no need for the progn within the if statement, since you are only doing one thing per if statement.

Now it looks like you need to check your other two functions. I get this error when trying to run it

Command: cloud
_pline
Specify start point:
Current line-width is 0.0000
Specify next point or [Arc/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]:
Specify next point or [Arc/Close/Halfwidth/Length/Undo/Width]: c
Command:
Minimum arc length: 0.5 Maximum arc length: 0.5
Requires numeric distance or two points.
; error: Function cancelled

Specify minimum length of arc <0.5>: *Cancel*

.T.
2006-02-24, 11:21 PM
Hi again,

The program crashes with the error Tim mentioned on mine when I'm in decimal, but works in architectural units. You may need to check the lunits system variable and set the size accordingly.

T.Willey
2006-02-24, 11:34 PM
Yup. Good point Tim, and it worked here in architectural units. That just seems so wrong. Complimenting someone named Tim, makes me feel like I'm talking to myself. :grin:

.T.
2006-02-25, 01:40 AM
Funny, I almost wrote "the other Tim" in my last post here :) Looking throught the member list, there are quite a few of us here.