AddPolyline Method Back to Methods Reference
Creates a polyline from a list of vertices.

Signature

VL : RetVal = (vla-AddPolyline object VertricesList)

• Object : ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.
• VerticesList : Variant (array of doubles); input-only
An array of OCS coordinates used to create the polyline vertices. Each vertex is represented with three elements, with the first two being the X and Y coodinates in OCS; the third element is ignored. At least two points (six elements) are required for constructing a polyline object. The array size must be a multiple of three.
• RetVal : Polyline object
The newly created Polyline object.

Remarks

To create a polyline containing arcs, first create the straight polyline, then set the bulge at specific vertices using the SetBulge method.
This method exists for backward compatibility only. Use the new AddLightweightPolyline method to create polylines with an optimized format that saves memory and disk space.

Coordinates can be converted to and from the OCS using the TranslateCoordinates method.

Example :

 ``` (defun c:al-addpolyline (/ pt ptlist tmp myobj a) (setq thisdrawing (vla-get-activedocument (vlax-get-acad-object))) (setq mspace (vla-get-modelspace thisdrawing)) (setq pt (getpoint "\nSpecify start point: ")) ;; Start by assembling a list of points (setq ptlist (cons pt ptlist)) (while (setq pt (getpoint "\nSpecify next point: " pt)) (setq ptlist (cons pt ptlist)) ) ;; "dissolve" the points into atoms with append: (setq ptlist (apply 'append ptlist)) ;; If number of coordinates in point list is not ;; a multiple of 3 then a polyline can't be made. ;; If it's a multiple of 3 then put the point ;; list into an array and pass it on to vla-addPolyline: (if (= (rem (length ptlist) 3) 0) (progn (setq tmp (vlax-make-safearray vlax-vbDouble (cons 0 (- (length ptlist) 1)) ) ) (vlax-safearray-fill tmp ptlist) (setq myobj (vla-addPolyline mspace tmp)) ) (princ "\nerror: Polyline could not be created") ) ;; Just for the fun of it, convert every other segment ;; to a semicircle. First, get number of vertex points ;; and then set the bulge factor for every second point: (if myobj (progn (setq coords (vla-get-coordinates myobj)) (setq coords (vlax-safearray->list (vlax-variant-value (vla-get-coordinates myobj)) ) ) (setq a 0) (while (< a (/ (length coords) 3)) (if (= (rem a 2) 0) (vla-setBulge myobj a 1.0) ) (setq a (1+ a)) ) ) ) ) ```

 Search the WWW Search AfraLisp