AddVertex Method (ActiveX)

Adds a vertex to a lightweight polyline or a section.

Supported platforms: Windows only

Signature

VBA:

object.AddVertex Index, Point
object

Type: LWPolyline, Section

The objects this method applies to.

Index

Access: Input-only

Type: Long

The index in the array of vertices where the vertex is to be added. Index must be a positive integer. The first element of the array is index 0.

Point

Access: Input-only

Type: Variant (three-element array of doubles)

The 3D OCS coordinates at which to create the new vertex.

Return Value (RetVal)

No return value.

Remarks

LWPolyline: The vertex specifies the endpoint for a new line segment. To add an arc segment to a lightweight polyline, first create the line segment, and then add a "bulge" to the individual segment that is to become an arc. To add a bulge value to a segment, use the SetBulge method.

Section: The vertex specifies a point on the section line.

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

Examples

VBA:

Sub Example_AddVertex()
    ' This example creates a lightweight polyline in model space.
    ' It then adds a vertex to the polyline.

    Dim plineObj As AcadLWPolyline
    Dim points(0 To 9) As Double
    
    
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
        
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    ZoomAll
    MsgBox "Add a vertex to the end of the polyline.", , "AddVertex Example"
    
    ' Define the new vertex
    Dim newVertex(0 To 1) As Double
    newVertex(0) = 4: newVertex(1) = 1
    
    ' Add the vertex to the polyline
    plineObj.AddVertex 5, newVertex
    plineObj.Update
    MsgBox "Vertex added.", , "AddVertex Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddVertex()
    ;; This example creates a lightweight polyline in model space.
    ;; It then adds a vertex to the polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Define the 2D polyline points
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 9)))
    (vlax-safearray-fill points '(1 1
                                  1 2
                                  2 2
                                  3 2
                                  4 4
                                 )
    )
        
    ;; Create a lightweight Polyline object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-ZoomAll acadObj)
    (alert "Add a vertex to the end of the polyline.")
    
    ;; Define the new vertex
    (setq newVertex (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill newVertex '(4 1))
    
    ;; Add the vertex to the polyline
    (vla-AddVertex plineObj 5 newVertex)
    (vla-Update plineObj)
    (alert "Vertex added.")
)