Table of contents
TOC
Collapse the table of content
Expand the table of content

Shape.DrawPolyline Method (Visio)

office 365 dev account|Last Updated: 6/12/2017
|
1 Contributor

Creates a shape whose path is a polyline along a given set of points.

Syntax

expression . DrawPolyline( xyArray() , Flags )

expression A variable that represents a Shape object.

Parameters

NameRequired/OptionalData TypeDescription
xyArray()RequiredDoubleAn array of alternating x and y values that defines points in the new shape's path.
FlagsRequiredIntegerFlags that influence how the shape is drawn.

Return Value

Shape

Remarks

The DrawPolyline method creates a new shape whose path consists of a sequence of line segments and whose endpoints match the points specified in xyArray . Calling the DrawPolyline method is equivalent to calling the DrawSpline method with a tolerance of zero (0) and a flag of visSplineAbrupt .

The control points should be in internal drawing units (inches) with respect to the coordinate space of the page, master, or group in which the new shape is being created. The passed array should be a type SAFEARRAY of 8-byte floating point values passed by reference (VT_R8|VT_ARRAY|VT_BYREF). This is how Microsoft Visual Basic passes arrays to Automation objects.

The Flags argument is a bitmask that specifies options for drawing the new shape. Its value can include visPolyline1D (8) or visPolyarcs (256). If Flags includes:

  • visPolyline1D and if the first and last points in xyArray don't coincide, the DrawPolyline method produces a shape with one-dimensional (1-D) behavior; otherwise, it produces a shape with two-dimensional (2-D) behavior.

  • visPolyarcs , Microsoft Visio will produce a sequence of arcs rather than a sequence of line segments; xyArray should specify the initial x,y point of the sequence followed by x,y bow triples. Visio will produce a shape with EllipticalArcTo rows where the bow of the arc matches the specified value.

If the first and last points in xyArray coincide, the DrawPolyline method produces a filled shape.

Example

The following example shows how to draw two polyline shapes that have 2-D and 1-D behavior, respectively, on the active page.


Public Sub DrawPolyline_Example() 

 Dim vsoShape As Visio.Shape 
 Dim adblXYPoints(1 To 8) As Double 
 Dim intCounter As Integer 

 'Initialize array with coordinates. 
 adblXYPoints(1) = 1 
 adblXYPoints(2) = 1 
 adblXYPoints(3) = 3 
 adblXYPoints(4) = 3 
 adblXYPoints(5) = 5 
 adblXYPoints(6) = 1 
 adblXYPoints(7) = 1 
 adblXYPoints(8) = 2 

 'Use the DrawPolyline method to draw a shape that has 2-D behavior. 
 Set vsoShape = ActivePage.DrawPolyline(adblXYPoints, 0) 

 'Increase the Y-coordinate of the array by 4 to separate 
 'the next shape drawn from the first. 
 For intCounter = 2 To UBound(adblXYPoints) Step 2 
 adblXYPoints(intCounter) = adblXYPoints(intCounter) + 4 
 Next intCounter 

 'Use the DrawPolyline method to draw a shape that has 1-D behavior. 
 Set vsoShape = ActivePage.DrawPolyline(adblXYPoints, visPolyline1D) 

End Sub
© 2017 Microsoft