AddVertex method example


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 MyPoints(0 To 7) As Double
    ' Define the 2D polyline points
    MyPoints(0) = 1: MyPoints(1) = 1
    MyPoints(2) = 3: MyPoints(3) = 1
    MyPoints(4) = 3: MyPoints(5) = 4
    MyPoints(6) = 6: MyPoints(7) = 4
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(MyPoints)
    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) = 6: newVertex(1) = 1
    ' Add the vertex to the polyline
    plineObj.AddVertex 4, newVertex
    plineObj.Update
    MsgBox "Vertex added.", , "AddVertex Example"
End Sub

© Bricsys NV. All rights reserved.