Table of contents

Master.DrawSpline 方法 (Visio)Master.DrawSpline Method (Visio)

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

创建一个新建形状,其路径沿着给定的点序列。Creates a new shape whose path follows a given sequence of points.


表达式DrawSplinexyArray()公差标志expression . DrawSpline( xyArray() , Tolerance , Flags )

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


名称Name必需/可选Required/Optional数据类型Data Type说明Description
xyArray()xyArray()必需RequiredDoubleDouble交替的新形状路径中定义的点的_x_和_y_值的数组。An array of alternating x and y values that define points in the new shape's path.
容差Tolerance必需RequiredDoubleDouble新建形状的路径必须接近于给定点的程度。How closely the path of the new shape must approximate the given points.
FlagsFlags必需RequiredIntegerInteger影响形状绘制方式的标志。Flags that influence how the shape is drawn.

返回值Return Value



DrawSpline方法会创建一个新建形状,其路径在给定的点数组给定的公差范围内。若要完全适合给定的点,请指定公差为零 (0)。通常, DrawSpline方法会使样条线段点,但有时也会生成线条或圆弧线段在新形状中。The DrawSpline method creates a new shape whose path falls within the given tolerance of the given array of points. To fit the given points exactly, specify a tolerance of zero (0). Typically, the DrawSpline method fits spline segments through the points, but it sometimes produces line or circular arc segments in the new shape.

控制点和公差以在其中创建新建形状的页面、主控形状或组的坐标空间的内部绘图单位(英寸)表示。传递的数组应该是 SAFEARRAY 类型的由引用 (VT_R8|VT_ARRAY|VT_BYREF) 传递的 8 字节浮点值。这是 Microsoft Visual Basic 向自动对象传递数组的方式。The control points and tolerance are 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 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 error from the points to the path of the resulting shape is roughly within tolerance. When the number of points is large, the actual error may sometimes exceed the prescribed tolerance.

Flags_参数是一个位掩码,指定用于绘制新建形状的选项。其值应为零个或一个或多个下列值的组合。The _Flags parameter is a bitmask that specifies options for drawing the new shape. Its value should be zero or a combination of one or more of the following values.

visSplinePeriodicvisSplinePeriodic1 (&;H1)1(&;H1)
visSplineDoCirclesvisSplineDoCircles2 (&;H2)2(&;H2)
visSplineAbruptvisSplineAbrupt4 (&;H4)4(&;H4)
visSpline1DvisSpline1D8 (&;H8)8(&;H8)

如果_标志_包括visSplinePeriodic ,并且满足以下条件时,应用程序将尝试绘制一个周期性样条。否则,Visio 绘制一个非周期性样条:If Flags includes visSplinePeriodic and the following conditions are met, the application attempts to draw a periodic spline. Otherwise, Visio draws a non-periodic spline:

  • 最后一个点必须与第一个点重叠。The last point must be a repetition of the first one.

  • 如果标志visSplineAbrupt也包括在内,整个封闭的路径轮廓的点必须免费的突然变化的方向和曲率。If the flag visSplineAbrupt is included as well, the entire closed path outlined by the points must be free of abrupt changes of direction and curvature.

如果_标志_包括visSplineDoCircles ,Microsoft Visio 认识到在给定的点数组中的圆弓形,并生成圆弧,而不是对这些段样条行。If Flags includes visSplineDoCircles , Microsoft Visio recognizes circular segments in the given array of points and generates circular arcs instead of spline rows for those segments.

如果_标志_包括visSplineAbrupt ,Visio 将中断样条发出的方向或曲度发生了突然变化的点的轨迹中。由三个相邻点 A,B,C 在列表中,B 和线段 AC 之间的距离的两倍多的公差定义方向发生突然变化。应用程序还将考虑 B 点的线段 AB 或 BC 之一就是多倍另可发生了突然变化。在检测到发生了突然变化时的点,应用程序结束当前一段 (线条、 弧线或样条),并开始一个新。If Flags includes visSplineAbrupt , Visio breaks the spline whenever it detects an abrupt change of direction or curvature in the point's trail. An abrupt change of direction is defined by three consecutive points A, B, C in the list, for which the distance between B and the line segment AC is more than twice the tolerance. The application also considers point B to be an abrupt change if one of the segments AB or BC is more than twice as long as the other. At a point where an abrupt change is detected, the application ends the current piece (line, arc, or spline) and starts a fresh one.

如果_标志_包括visSpline1D和_xyArray()中的第一个和最后一个点不重合, DrawSpline方法会产生具有一维 (1-d) 行为的形状,否则,它将生成具有的形状二维 (2-d) 行为。If _Flags includes visSpline1D and the first and last points in xyArray() don't coincide, the DrawSpline method produces a shape that has one-dimensional (1-D) behavior, otherwise, it produces a shape that has two-dimensional (2-D) behavior.

如果在_xyArray()中的第一个和最后一个点做重合, DrawSpline方法会产生一个填充的形状。If the first and last points in _xyArray() do coincide, the DrawSpline method produces a filled shape.


以下示例显示如何绘制一个通过五个任意点的周期性样条,同时要求样条与各个点之间的距离在 0.25(绘图)英寸范围内。该示例允许 Visio 在新建形状的路径上发生突然变化的点处开始新段。The following example shows how to draw a periodic spline through five arbitrary points, requiring that the spline approach within 0.25 (drawing) inches of each point. It allows Visio to start new segments in the path of the new shape at points considered abrupt.

Public Sub DrawSpline_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 components (array elements 1,3,5,7,9) to 1,2,3,4,5 
 adblXYPoints((intCounter * 2) - 1) = intCounter 

 'Set y components (array elements 2,4,6,8,10) to f(i) 
 adblXYPoints(intCounter * 2) = (intCounter * intCounter) - (7 * intCounter) + 15 
 Next intCounter 

 Set vsoShape = ActivePage.DrawSpline(adblXYPoints, 0.25, visSplineAbrupt) 

End Sub
© 2018 Microsoft