Jump to content

Getpoint & repeat


leong1221

Recommended Posts

Posted

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??

Posted

Hi,

You can use While function.

 

(while (setq pt (getpoint "\nSpecify a point :"))
 (setq pts (cons pt pts))
)

Posted

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

Posted

:P 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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...