Shape.DrawBezier method (Visio)

Creates a shape whose path is defined by the supplied sequence of Bezier control points.

Syntax

expression. DrawBezier( _xyArray()_ , _degree_ , _Flags_ )

expression A variable that represents a Shape object.

Parameters

Name Required/Optional Data type Description
xyArray() Required Double An array of alternating x and y values that define the Bezier control points for the new shape.
degree Required Integer The degree of the Bezier curve.
Flags Required Integer Flags that influence how the shape is drawn.

Return value

Shape

Remarks

The xyArray() and degree parameters must meet the following conditions:

1 <= degree <= 9

The number of points must be k * degree + 1, where k is a positive integer. If the first point is called p0 , for any integer m between 1 and k , p(m * degree) is assumed to be the last control point of a Bezier segment, as well as the first control point of the next.

The result is a composite curve that consists of k Bezier segments. The input points from xyArray() define the curve's control points. If you want a smooth curve, make sure the points p(n - 1) , pn , and p(n + 1) are co-linear whenever n = m * degree with an integer m. The composite Bezier curve is represented in the application as a B-spline with integer knots of multiplicity = degree.

The control points should be in internal drawing units (inches) with respect to the coordinate space of the page, master, or group where the shape is being drawn. The passed array should be a 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 should be zero (0) or visSpline1D (8).

If Flags is visSpline1D and the first and last points in xyArray() don't coincide, the DrawBezier method produces a shape with one-dimensional (1D) behavior; otherwise, it produces a shape with two-dimensional (2D) behavior.

If the first and last points in xyArray() do coincide, the DrawBezier method produces a filled shape.

Example

The following example shows how to draw a Bezier curve through five arbitrary points on the active page.

 
Public Sub DrawBezier_Example() 
 
 Dim vsoShape As Visio.Shape 
 Dim intCounter As Integer 
 Dim adblXYPoints(1 To (5 * 2)) As Double 
 
 For intCounter = 1 To 5 
 
 'Set x-coordinates (array elements 1,3,5,7,9) to 1,2,3,4,5 
 adblXYPoints((intCounter * 2) - 1) = intCounter 
 
 'Set y-coordinates (array elements 2,4,6,8,10) to f(intCounter) 
 adblXYPoints(intCounter * 2) = (intCounter * intCounter) - (7 * intCounter) + 15 
 
 Next intCounter 
 
 Set vsoShape = ActivePage.DrawBezier(adblXYPoints, 2, visSpline1D) 
 
End Sub

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.