Share via


DrawPolyline Method [Visio 2003 SDK Documentation]

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

objRet = object**.DrawPolyline**(xyArray, flags)

objRet     A Shape object that represents the new polyline.

object     Required. An expression that returns a Page, Master, or Shape object in which to draw the shape.

xyArray     Required Double. An array of alternating x and y values that defines points in the new shape's path.

flags     Required Integer. Flags that influence how the shape is drawn.

Version added

2000

Remarks

The DrawPolyline method creates a new shape whose path consists of a sequence of line segments and whose end points 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 bit mask 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 Office 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 coordinates 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  

Applies to | Master object | Page object | Shape object