Hi ALL,
I would like to learn "LOOP" with LISP.
The following is a sample:
Your helps are much appreciated.Code:Do TASK_01. Test CONDITION_01. If CONDITION_01 is nil, repeat TASK_01 until CONDITION_01 is true. Then the routine stops.
|
Hi ALL,
I would like to learn "LOOP" with LISP.
The following is a sample:
Your helps are much appreciated.Code:Do TASK_01. Test CONDITION_01. If CONDITION_01 is nil, repeat TASK_01 until CONDITION_01 is true. Then the routine stops.
Last edited by BoKirra; 2009-03-09 at 11:52 PM.
A sample as below:
How to write this routine?Code:1) Define a diameter (setq Hole_Diameter (getreal "Enter Diameter: ")) 2) Draw a circle (command "circle" Insert_point "d" Hole_Diameter) 3) Repeat step 1 and 2 until Hole_Diameter = 50 4) Draw a center mark to the circle only when its Hole_Diameter = 50 (command "line" point01 point02 "") ;point01 & point02 were predefined. (command "line" point03 point04 "") ;point03 & point04 were predefined. 5) Routine stops. Note: This routine would draw as many circles as user inputted. The routine would not stop until a 50mm diameter circle drawn & center mark added. And there would be only one single circle drawn with 50mm diameter & only it would have a center mark.
Thanks in advance.
Last edited by BoKirra; 2009-03-10 at 09:47 PM.
Hi,
Code:(while (/= 50.0 (setq Hole_Diameter (getreal "Enter Diameter: "))) (command "_.circle" Insert_point "_d" Hole_Diameter) ) (command "_.circle" Insert_point 25.0) (command "_.line" point01 point02 "") (command "_.line" point03 point04 "")
It can be even simpler, the test is both checking & performing the action:Yours wouldn't work since condition_01 is simply a variable holding a value, not a function performing some action. That's whyandrea had the (setq ...) warped inside a defun and then calling the defun in the while loop.Code:(while (not (setq condition_01 (entsel "\nSelect your entity: "))))