View Full Version : basic lisp programming
pkreusch
2009-07-29, 06:37 PM
How would I write a command like "pline" that waits for the user to finish the command before continuing to the next line?
example-
(command "pline")
(command "move")
Using these 2 lines in my program causes the first user input of the "pline" command to be "move"
Command: 'VLIDE pline
Specify start point: move
Invalid point.
Thanks..........
ccowgill
2009-07-29, 08:22 PM
How would I write a command like "pline" that waits for the user to finish the command before continuing to the next line?
example-
(command "pline")
(command "move")
Using these 2 lines in my program causes the first user input of the "pline" command to be "move"
Command: 'VLIDE pline
Specify start point: move
Invalid point.
Thanks..........
try Pause after "pline", there is something else with using the cmdactive sysvar, but I cant remember what it was right now.
irneb
2009-07-29, 08:23 PM
You use pause and a while loop checking the CMDACTIVE system variable for its 1st bit set.(command "._PLINE")
(while (> (logand (getvar"CMDACTIVE") 1) 0)
(command pause)
)
(command "._MOVE")From the normal Help file CMDACTIVE is set to 1 when a normal command is running. I suggest using logand (however in most instances a normal (>= ... 1) would also work). The logand is described in this thread (http://forums.augi.com/showthread.php?t=102783&highlight=logand) see my post #4 in particular.
Then the (command pause) waits for user input. The while loop continues sending a pause until the user's completed the PLINE and the command has ended (i.e. CMDACTIVE is now set to 0 - or other than the 1st bit set to 1). Then the move command is executed.
ccowgill
2009-07-29, 08:25 PM
You use pause and a while loop checking the CMDACTIVE system variable for its 1st bit set.(command "._PLINE")
(while (> (logand (getvar"CMDACTIVE") 1) 0)
(command pause)
)
(command "._MOVE")From the normal Help file CMDACTIVE is set to 1 when a normal command is running. I suggest using logand (however in most instances a normal (>= ... 1) would also work). The logand is described in this thread (http://forums.augi.com/showthread.php?t=102783&highlight=logand) see my post #4 in particular.
Then the (command pause) waits for user input. The while loop continues sending a pause until the user's completed the PLINE and the command has ended (i.e. CMDACTIVE is now set to 0 - or other than the 1st bit set to 1). Then the move command is executed.
That's what I was thinking of, thanks for jogging my memory
pkreusch
2009-07-30, 01:31 PM
Thank you to you both for your time!!
I have been playing with lisp programming for about 5 years and thanks to you guys, I now have my first lisp program finished! It's only a few lines but it gets the job done.
See below
_________________________
;Creates a polyline around an area, automatically closes the
;pline, and automatically prompts the user to place
;a text with the square footage inside the area with the
;area rounded to the nearest square foot. Load lisp file
;and type "at" at the command prompt. Follow prompts to first
;draw the pline by selecting points and then place the cursor
;where you want the middle point of your text.
(defun c:AT(/ area)
(setvar "cmdecho" 1)
(command "._PLINE")
(while (> (logand (getvar "CMDACTIVE") 1) 0)
(command pause)
)
(command "pedit" "l" "c" "")
(command "area" "o" "l")
(setq area(rtos(/(getvar "area")144)2 0))
(command "text" "m" pause (getvar "textsize") "0" (strcat area " s.f."))
)
irneb
2009-07-30, 09:55 PM
To look into making use of Fields so your Area becomes automatically updated if someone stretches the polyline, check my add-on attached. Does quite a lot, but I've given descriptive comments.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.