Getpoint & repeat
Hi Guys,I am writing a lisp using Getpoint (mouse input) and sometime i need 1 point sometime 2 sometime 3 and setq each point to pt1 pt2 pt3.
If i want to make this lisp keep asking Getpoint until user press the spacebar to proceed to next step, should i use repeat?? Hi,
You can use While function.
(while (setq pt (getpoint "\nSpecify a point :")) (setq pts (cons pt pts))) Check out this tutorail:
http://www.afralisp.net/autolisp/tutorials/program-looping.php
Exactly this question is explained there.. This will assign to a variable pt1, pt2, pt3 etc until enter/spacebar is pressed.
(defun c:loop2 (/ pt ptlist cnt num) (setq ptlist nil) (while (setq pt (getpoint "\nEnter Point or RETURN when done: ")) (append ptlist (list pt))) ) ;_ end of while (setq cnt (length ptlist)) (setq num (+ cnt 1)) (repeat cnt (set (read (strcat "pt" (itoa (setq num (- num 1))))) (last ptlist)) (setq ptlist (vl-remove (last ptlist) ptlist)) ) ;_ end of repeat (princ)) ;_ end of defun Recursive:
; (getpoints nil "\n>>> Specify point: ")(defun getpoints ( p m ) (cond ((not (setq p (apply 'getpoint (append (if p (list p)) (if m (list m)))))) p) ((cons p (getpoints p m))))); defun getpoints
页:
[1]