Tharwat Posted June 29, 2010 Share Posted June 29, 2010 Hello everyone. (setq points (getint"\n Nos. of X Points: ") ;; <--- any number of points Dist (getint"\nLength of Distance: ");; <--- any length start (getpoint"\nSpecify the start point:") ) (setq pt1........ pt2.......... pt3........... and so on How to create the following points of start point automatically according to the numbers of points .....????? Many Thanks Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 29, 2010 Share Posted June 29, 2010 In AutoLISP you can create variables at run-time: (setq theIndex 1) (repeat points (set (read (strcat "pt" (itoa theIndex))) (getpoint (strcat "\nIndicate point " (itoa theIndex) ": "))) (setq theIndex (1+ theIndex)) ) Regards, Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 29, 2010 Share Posted June 29, 2010 I'd put them in a list. If you define variables for each point, you'll have a fun time trying to access each. eg. (defun test (/ num dist lst pt) (initget 6) (if (and (setq num (getint "\nSpecify number of X points: ")) (not (initget 6)) (setq dist (getdist "\nSpecify distance: ")) (car (setq lst (list (getpoint "\nSpecify first point: ")))) ) (progn (while (> num (length lst)) (if (setq pt (getpoint (car lst) (strcat "\n" (itoa (- num (length lst))) " point(s) left.\nSpecify next point: " ) ) ) (grdraw (cadr (setq lst (cons pt lst))) pt 3 1) ) ) (redraw) (reverse lst) ) ) ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 29, 2010 Author Share Posted June 29, 2010 Thanks a lot msasu But I try it with the following code ... and it gives me an error to fixnump ??? (defun c:qq (/ theindex points) (setq theIndex (getint"\n Nos. of X Points: ")) (repeat points (set (read (strcat "pt" (itoa theIndex))) (getpoint (strcat "\nIndicate point " (itoa theIndex) ": "))) (setq theIndex (1+ theIndex)) )) Any complete example please ? Faithful Tharwat Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 29, 2010 Share Posted June 29, 2010 The code should look like: (defun c:qq (/ theindex points) [color=red](setq points (getint"\n Nos. of X Points: "))[/color] [color=red](setq theIndex 1)[/color] (repeat points (set (read (strcat "pt" (itoa theIndex))) (getpoint (strcat "\nIndicate point " (itoa theIndex) ": "))) (setq theIndex (1+ theIndex)) ) [color=red](princ)[/color] ) Regards, Quote Link to comment Share on other sites More sharing options...
MSasu Posted June 29, 2010 Share Posted June 29, 2010 And for sure the method suggested by @alanjt is much user-friendly (I mean programmer-friendly)... Regards, Quote Link to comment Share on other sites More sharing options...
alanjt Posted June 29, 2010 Share Posted June 29, 2010 And for sure the method suggested by @alanjt is much user-friendly (I mean programmer-friendly)... Regards, Thanks msasu. 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.