@vishshreevT578L wrote:
(DEFUN C:EXTRPOINTS ()
(SETQ POLYENT (ENTGET (CAR (ENTSEL "\nSelect a polyline: "))))
CAN I MAKE A LIST OF ALL THE COORDINATES OF A POLYLINE USING "FOREACH" HERE, IF I CAN ....HOW?
If you mean the vertices, you could, but if it's a lightweight Polyline, it's perhaps easier to do it by leaving out all entity data entries that don't start with a 10 [the vertices]:
(setq VertexList
(mapcar 'cdr ; take the 10's off the beginning of each
(vl-remove-if-not
'(lambda (x) (= (car x) 10)); a vertex entry
POLYENT
); vl-remove...
); mapcar
); setq
[If you really mean just the raw coordinates, not differentiated into point lists, check out the 'Coordinates VLA Property, which you can get from either a lightweight or a heavy Polyline.]
But yes, there is a way to do it with (foreach):
(foreach entry POLYENT
(if (= (car entry) 10); it's a vertex entry
(setq VertexList (cons (cdr entry) VertexList)); then -- add point list [without the 10] to collective list
); if
); foreach
Use (reverse) on the result if you need them in the Polyline's drawn order, or use (reverse) on POLYENT at the beginning so it will build the list the other way.
Kent Cooper, AIA