Table of contents

Shape.DrawPolyline 方法 (Visio)Shape.DrawPolyline Method (Visio)

office 365 dev account|上次更新日期: 2018/3/13
2 参与人员

创建一个形状,其路径为沿着一组给定点的折线。Creates a shape whose path is a polyline along a given set of points.


表达式DrawPolyline( xyArray()标志)expression . DrawPolyline( xyArray() , Flags )

表达式_一个表示一个Shape对象的变量。_expression A variable that represents a Shape object.


名称Name必需/可选Required/Optional数据类型Data Type说明Description
xyArray()xyArray()必需RequiredDoubleDouble在新形状的路径定义点交替出现_x_和_y_值的数组。An array of alternating x and y values that defines points in the new shape's path.
FlagsFlags必需RequiredIntegerInteger影响形状绘制方式的标志。Flags that influence how the shape is drawn.

返回值Return Value



DrawPolyline方法创建一个新建形状,其路径由一系列的直线段组成,其终结点匹配在_xyArray_中指定的点。调用DrawPolyline方法等效于调用DrawSpline方法与公差为零 (0) 和visSplineAbrupt的一个标志。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 .

控制点应该使用在其中创建新建形状的页面、主控形状或组的坐标空间的内部绘图单位(英寸)。传递的数组应该是 SAFEARRAY 类型的由引用 (VT_R8|VT_ARRAY|VT_BYREF) 传递的 8 字节浮点值。这是 Microsoft Visual Basic 向自动对象传递数组的方式。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.

Flags_参数是一个位掩码,指定用于绘制新建形状的选项。其值可以包括visPolyline1D (8) 或visPolyarcs (256)。如果_标志_包括: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和_xyArray_中的第一个和最后一个点不重合,如果DrawPolyline方法可生成形状与一维 (1-d) 行为;否则,它将生成二维 (2-d) 行为的形状。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 将产生弧序列,而不是一系列的直线段;xyArray_应指定初始_x、 y_跟_x,y_弓三元组的序列点。Visio 会产生 EllipticalArcTo 行弧弓与指定的值相匹配的形状。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.

如果在_xyArray_中的第一个和最后一个点重合, DrawPolyline方法将产生一个填充的形状。If the first and last points in xyArray coincide, the DrawPolyline method produces a filled shape.


以下示例显示如何在活动页上绘制两个分别具有二维和一维行为的折线形状。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
© 2018 Microsoft