collect coordinates as a list

collect coordinates as a list

Anonymous
Not applicable
336 Views
4 Replies
Message 1 of 5

collect coordinates as a list

Anonymous
Not applicable
hi
I'm sure this has been answered before, but with the news group in its
current state of where ever land, I'm posting the question again.

How do I store coordinates in a list so that I can retrieve them later. I'm
wanting to store the coordinates as they are entered. and then use that data
to replace a line with a leader or find the angle between two points etc.
The best I managed (with my limited list experince) was saving the points
more as a string rather than a point. This works fine for the drawing a new
line but didn't work for finding the angle between two points contained in
the list.

I guess I'm going about it wrong.

Any help or clues would be appreciated.
thanks
CJ Follmer
0 Likes
337 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
There's probably a better way but this should get you started:

;;; Returns a list of points selected by the user
(defun collect-points (/ pt lst)
(setq pt T)
(while pt
(if lst
(setq pt (getpoint (car lst) "\nSelect point: "))
(setq pt (getpoint "\nSelect point: "))
)
(if pt
(setq lst (cons pt lst))
)
)
(reverse lst)
)

--
Get free software and more at http://www2.stonemedia.com/franko

"CJ Follmer" wrote in message
news:eee1eec.-1@WebX.SaUCah8kaAW...
> hi
> I'm sure this has been answered before, but with the news group in its
> current state of where ever land, I'm posting the question again.
>
> How do I store coordinates in a list so that I can retrieve them later.
I'm
> wanting to store the coordinates as they are entered. and then use that
data
> to replace a line with a leader or find the angle between two points etc.
> The best I managed (with my limited list experince) was saving the points
> more as a string rather than a point. This works fine for the drawing a
new
> line but didn't work for finding the angle between two points contained in
> the list.
>
> I guess I'm going about it wrong.
>
> Any help or clues would be appreciated.
> thanks
> CJ Follmer
>
0 Likes
Message 3 of 5

Anonymous
Not applicable
In LISP, 3D points are stored as a list of three doubles.

You can create a list of points using the (cons) or (append)
functions.

For example (using cons):

(while (setq p (getpoint "\nEnter point: "))
(setq point_list (cons p point_list))
)


This causes each point entered to be added to the
list assigned to 'point_list', in the reverse order
which they were supplied.

You can use the (reverse) function to put the points
in the same order they were entered:

(setq point_list (reverse point_list))

You can process the list of points one point at a
time, using (foreach), like this:

(foreach point point_list
(print point) ;; print it out
)

You can draw a line through all of the points in
the point list, like this:

(command "._LINE")
(apply 'command point_list)
(command "")

CJ Follmer wrote:
>
> hi
> I'm sure this has been answered before, but with the news group in its
> current state of where ever land, I'm posting the question again.
>
> How do I store coordinates in a list so that I can retrieve them later. I'm
> wanting to store the coordinates as they are entered. and then use that data
> to replace a line with a leader or find the angle between two points etc.
> The best I managed (with my limited list experince) was saving the points
> more as a string rather than a point. This works fine for the drawing a new
> line but didn't work for finding the angle between two points contained in
> the list.
>
> I guess I'm going about it wrong.
>
> Any help or clues would be appreciated.
> thanks
> CJ Follmer

--
/*********************************************************/
/* Tony Tanzillo Design Automation Consulting */
/* Programming & Customization for AutoCAD & Compatibles */
/* ----------------------------------------------------- */
/* tony.tanzillo@worldnet.att.net */
/* http://ourworld.compuserve.com/homepages/tonyt */
/*********************************************************/
0 Likes
Message 4 of 5

Anonymous
Not applicable
thanks guys

I'll give it a try.

Just got the NG back on my news reader AGAIN!
very frustrating.
0 Likes
Message 5 of 5

Anonymous
Not applicable
Thanks guys, got it to work like a charm.
0 Likes