PDA

View Full Version : Creating a list Polyline vertices


cadconcepts
2008-07-16, 03:23 PM
Hi All-

I am working on a larger routine and I am currently focusing my attention on a portion that will store the vertices of a selected polyline. For some reason I am having trouble getting the routine to built the list. I was hoping that someone could tell me what I am doing wrong. Thanks in advance.

Manuel A. Ayala

'gile'
2008-07-16, 04:31 PM
Hi,

Here's a routine which returns a polyline vertices list (WCS coordinates).
It uses the vlax-curve* functions.
It works with any polyline type.

;;; Poly-Pts (gile)
;;; Returns the vertices list of any type of polyline (WCS coordinates)
;;;
;;; Argument
;;; pl : a polyline (ename or vla-object)

(defun Poly-Pts (pl / pa pt lst)
(vl-load-com)
(setq pa (if (vlax-curve-IsClosed pl)
(vlax-curve-getEndParam pl)
(+ (vlax-curve-getEndParam pl) 1)
)
)
(while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))
(setq lst (cons pt lst))
)
)

You can us it this way :

(if
(and (setq ent (car (entsel)))
(wcmatch (cdr (assoc 0 (entget ent))) "*POLYLINE")
)
(Poly-Pts ent)
)

cadconcepts
2008-07-16, 04:40 PM
Gile

Thanks for the help and the code. I will take a look at.

Manuel

prexem
2008-07-17, 12:22 AM
Hi All-

I am working on a larger routine and I am currently focusing my attention on a portion that will store the vertices of a selected polyline. For some reason I am having trouble getting the routine to built the list. I was hoping that someone could tell me what I am doing wrong. Thanks in advance.

Manuel A. Ayala

For obtain coordinates from a pline, try this code:

(vl-load-com)
(setq e (car (entsel "\nselect pline:"))
vla-e (vlax-ename->vla-object e)
vertexs (vlax-get vla-e 'coordinates)
)

aaronic_abacus
2008-07-17, 02:08 AM
;This autolisp snipet of code creates a list of polyline vertices to create a selection set.



(SETQ LP1 1)
(WHILE LP1
(PROMPT "\nSelect polyline boundary: ")
(SETQ PSS (SSGET ":S" '((0 . "LWPOLYLINE"))))
(IF (/= PSS NIL) (SETQ LP1 NIL) (PROMPT "\nNO POLYLINE SELECTED, TRY AGAIN. "))
);END LP1
(SETQ PEN (SSNAME PSS 0))
(SETQ PENL (ENTGET PEN))
(SETQ PPL (LIST))
(FOREACH N PENL
(PROGN
(SETQ PPA (CAR N))
(SETQ PPV (CDR N))
(IF (= PPA 10) (SETQ PPL (APPEND PPL (LIST PPV))))
));END N
(SETQ SHSS (SSGET "WP" PPL '((0 . "INSERT") (8 . "L-Irr-Sprayhead"))))