Alhazred Posted July 23, 2010 Share Posted July 23, 2010 In my routine I have to ask the user to pick some points, all the points he wants. To do that I've done like this and it works (setq points nil) (setq pt (getpoint "\nSelect a point:")) (while (/= pt nil) (setq points (cons pt points)) (setq pt (getpoint "\nSelect a point:")) ) In this way, the user, to stop the selection has to right click. Is there a better way to do the same? Quote Link to comment Share on other sites More sharing options...
MSasu Posted July 23, 2010 Share Posted July 23, 2010 This is the solution used by AutoCAD also to end a selection cycle. You may add the selection to WHILE test to avoid calling it twice: (while (/= (setq pt (getpoint "\nSelect a point <ENTER to exit>:")) nil) (setq points (cons pt points)) ) Regards, Quote Link to comment Share on other sites More sharing options...
gile Posted July 23, 2010 Share Posted July 23, 2010 Hi, (while (setq pt "\nSelect a point: ") (setq pts (cons pt pts)) ) Quote Link to comment Share on other sites More sharing options...
Alhazred Posted July 23, 2010 Author Share Posted July 23, 2010 Thanks to both of you. Quote Link to comment Share on other sites More sharing options...
alanjt Posted July 23, 2010 Share Posted July 23, 2010 (edited) Here's mine... (defun AT:GetPoints (/ lst pt) ;; Return list of picked points ;; Alan J. Thompson, 06.18.10 (if (car (setq lst (list (getpoint "\nSpecify first point: ")))) (progn (while (and (if (> (length lst) 2) (setq pt (initget 0 "Close") pt (getpoint (car lst) "\nSpecify next point [Close]: ") ) (setq pt (getpoint (car lst) "\nSpecify next point: ")) ) (/= pt "Close") ) (mapcar (function (lambda (a b) (and a b (grdraw a b 1 1)))) (setq lst (cons pt lst)) (cdr lst) ) ) (redraw) (reverse (cond ((= pt "Close") (cons (last lst) lst)) (lst) ) ) ) ) ) Edited July 23, 2010 by alanjt Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted July 23, 2010 Share Posted July 23, 2010 A few from my library, some more useful than others ;;---------------------=={ Get Points }==---------------------;; ;; ;; ;; Returns a list of selected points. ;; ;;------------------------------------------------------------;; ;; Author: Lee McDonnell, 2010 ;; ;; ;; ;; Copyright © 2010 by Lee McDonnell, All Rights Reserved. ;; ;; Contact: Lee Mac @ TheSwamp.org, CADTutor.net ;; ;;------------------------------------------------------------;; ;; Arguments: - None - ;; ;;------------------------------------------------------------;; ;; Returns: List of 3D Points ;; ;;------------------------------------------------------------;; (defun LM:GetPoints ( / lst pt ) ;; Lee Mac ~ 05.03.10 ;; Returns a list of selected Points (if (car (setq lst (list (getpoint "\nPick First Point: ")))) (while (setq pt (getpoint "\nPick Next Point: " (car lst))) (mapcar (function (lambda ( from to ) (grdraw from to 3 1)) ) (cdr (reverse (setq lst (cons pt lst)))) (reverse (cdr lst)) ) ) ) (redraw) (reverse lst) ) (defun LM:GetWindow ( / lst pt ) ;; Lee Mac ~ 05.03.10 ;; Returns a list of Points defining the window. (if (car (setq lst (list (getpoint "\nPick First Point: ")))) (while (setq pt (getpoint "\nPick Next Point: " (car lst))) (redraw) (mapcar (function (lambda ( from to ) (grdraw from to 3 1)) ) (append lst (list pt)) (setq lst (cons pt lst)) ) ) ) (redraw) (reverse lst) ) (defun LM:GetDynWindow ( / lst pt gr ) ;; Lee Mac ~ 31.01.10 (if (and (car (setq lst (list (getpoint "\nPick First Point: ")))) (princ "\nPick Next Point: ")) (while (setq pt (progn (while (and (= 5 (car (setq gr (grread 't 5 0)))) (listp (cadr gr))) (redraw) (mapcar (function (lambda ( from to ) (grdraw from to 3 1)) ) (cons (cadr gr) lst) (append lst (cdr gr)) ) ) (cond ( (listp (cadr gr)) (cadr gr) )) ) ) (cond ( pt (setq lst (cons pt lst)))) ) ) (redraw) (reverse lst) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.