AddPolyLine2

AddPolyLine2 adds a new polyline or spline polyline shape. Returns a Polyline object.

Syntax

object. AddPolyLine2( Vertices, PolylineType )

 

Parameter

Type

Default

Description

Vertices

Array of Doubles

required; A polyline is a collection of one or more connected line segments. The Vertices parameter provides the start point and end points of different line segments. End point of the first line segment is the start point for the next line segment and so on.

PolylineType

srfPolylineType

1

optional; The polyline type specifies the type of polyline to create. Use 1 for a polyline and 2 for a spline polyline.

Remarks

Either page units or map coordinates are used for the vertices. When the polygon is added to the plot, use page units for the vertices' coordinates. When the polygon is added to a map layer, use map coordinates to specify the vertices' coordinates. Vertices is an array containing alternating X, Y coordinates. This assumes the entire array is used. VB users can use

The number of vertices in the Vertices array must equal n*3+1 where n is the number of Bezier curves when the PolylineType is srfPTBezier. As always with cubic Bezier curves, there is a knot point on the curve, followed by two control points off the curve, followed by a knot point on the curve. The final knot point is shared with the next Bezier segment (if any), which explains the requirements on the number of vertices.

Example 1

This example demonstrates how to create a polyline using an array of doubles named Coordinates. The even numbered elements within the Coordinates array represent X values, while the odd numbered elements represent their corresponding Y values. The following code snippet would create a polyline joining points (4,1), (7,3) and (2,6).

'declare Polyline object

Dim Polyline As Object

'declare Coordinates array and set the element values

Dim Coordinates (5) As Double

Coordinates(0) = 4: Coordinates(1) = 1

Coordinates(2) = 7: Coordinates(3) = 3

Coordinates(4) = 2: Coordinates(5) = 6

'create the polyline

Set Polyline = Shapes.AddPolyLine2(Coordinates, srfPTPolyline)

Example 2

This example demonstrates how to create a spline polyline using an arrow of doubles named Points. The even numbered elements within the Points array represent X values, while the odd numbered elements represent their corresponding Y values. The first row is the first knot point. This is followed by the control point for the first knot, the first control point for the second knot. The fourth point is the second knot point. The following code snippet would create a spline polyline joining points (1,5), (3,5), and (5,5).

'declare Polyline object

Dim Polyline As Object

'declare Points array and set the element values

Dim Points (14) As Double

Points(0) = 1 : Points(1) = 5

'This is the first knot point

Points(2) = 1 : Points(3) = 7

Points(4) = 3 : Points(5) = 7

Points(6) = 3 : Points(7) = 5

'This is the second knot point

Points(8) = 3 : Points(9) = 3

Points(10) = 5 : Points(11) = 3

Points(12) = 5 : Points(13) = 5

'This is the third knot point

'create the spline polyline

Set Polyline = Shapes.AddPolyLine2(Points, srfPTBezier)

Example 3

This script displays all the methods and properties in the Shapes collection.

Used by: Shapes collection