' ----------------------------------------- ' 使用三点创建圆弧 CreateArcElement1() ' ----------------------------------------- Sub CreateArc1() ' 定义圆弧的三个点以及一个元素 Dim pntStart As Point3d ' 与圆心坐标的连线定出圆弧起始位置 Dim pntCenter As Point3d ' 圆心坐标 Dim pntEnd As Point3d ' 与圆心坐标的连线定出圆弧终止位置 Dim eleArc As ArcElement ' 初始化三个点 pntStart.X = 4 pntStart.Y = 2 pntStart.Z = 0 pntCenter.X = 2 pntCenter.Y = 0 pntCenter.Z = 0 pntEnd.X = 4 pntEnd.Y = 4 pntEnd.Z = 0 '创建三点圆弧 Set eleArc = CreateArcElement1(Nothing, pntStart, pntCenter, pntEnd) eleArc.Color = 3 ' 起终点不能为同一个点 If HasActiveModelReference And _ (pntStart.X <> pntEnd.X Or _ pntStart.Y <> pntEnd.Y Or _ pntStart.Z <> pntEnd.Z) Then ActiveModelReference.AddElement eleArc eleArc.Redraw Else Exit Sub End If End Sub ' ----------------------------------------- ' 使用起始角.终止角以及圆心创建圆弧 CreateArcElement2() ' ----------------------------------------- Sub CreateArc2() ' 定义两角度及圆心 Dim dblStartAngle As Double ' 起始角 Dim dblSweepAngle As Double ' 扫过角 Dim dblPrimaryRadius As Double ' 第一半径 Dim dblSecondaryRadius As Double ' 第二半径 Dim mtxRotation As Matrix3d Dim pntCenter As Point3d Dim eleArc As ArcElement ' 初始化变量 dblStartAngle = 3.1416 / 6 dblSweepAngle = 3.1416 dblPrimaryRadius = 5# dblSecondaryRadius = 15# pntCenter.X = 0 pntCenter.Y = 0 pntCenter.Z = 0 ' 创建圆弧 Set eleArc = CreateArcElement2(Nothing, pntCenter, dblPrimaryRadius, _ dblSecondaryRadius, mtxRotation, dblStartAngle, dblSweepAngle) eleArc.Color = 3 If HasActiveModelReference Then ActiveModelReference.AddElement eleArc eleArc.Redraw Else Exit Sub End If End Sub ' ----------------------------------------- ' 使用三点创建圆弧 CreateArcElement3() ' ----------------------------------------- Sub CreateArc3() ' 定义圆弧的三个点以及一个元素 Dim pntStart As Point3d ' 圆弧起点 Dim pntOnCurve As Point3d ' 圆弧上任意点 Dim pntEnd As Point3d ' 圆弧端点 Dim eleArc As ArcElement ' 初始化三个点 pntStart.X = 4 pntStart.Y = 2 pntStart.Z = 0 pntOnCurve.X = 2 pntOnCurve.Y = 4 pntOnCurve.Z = 0 pntEnd.X = 4 pntEnd.Y = 3 pntEnd.Z = 0 '创建三点圆弧 Set eleArc = CreateArcElement3(Nothing, pntStart, pntOnCurve, pntEnd) eleArc.Color = 3 ' 三点不同在一直线上,而且其中任意两点都不能相同(*未完成*) If HasActiveModelReference Then ActiveModelReference.AddElement eleArc eleArc.Redraw Else Exit Sub End If End Sub ' ----------------------------------------- ' 使用一点及一条射线创建圆弧 CreateArcElement4() ' ----------------------------------------- Sub CreateArc4() ' 定义圆弧的一个末点以及一条射线作为起始边 Dim pntEnd As Point3d Dim rayStart As Ray3d Dim eleArc As ArcElement ' 初始化变量 pntEnd.X = 0 pntEnd.Y = 3 pntEnd.Z = 0 rayStart.Origin.X = 0 rayStart.Origin.Y = 0 rayStart.Origin.Z = 0 rayStart.Direction.X = 3 rayStart.Direction.Y = 0 rayStart.Direction.Z = 0 Set eleArc = CreateArcElement4(Nothing, rayStart, pntEnd) eleArc.Color = 3 If HasActiveModelReference Then Application.ActiveModelReference.AddElement eleArc eleArc.Redraw End If End Sub ' ----------------------------------------- ' 使用一点及一条弦创建圆弧 CreateArcElement5() ' ----------------------------------------- Sub CreateArc5() ' 定义圆弧的一个末点以及一条弦作为起始边 Dim dblLong As Double ' 圆弧的长度 Dim pntPlane As Point3d ' 圆弧的方向 Dim segLine As Segment3d ' 圆弧的弦 Dim eleArc As ArcElement ' 初始化变量 pntPlane.X = 0 pntPlane.Y = 3 pntPlane.Z = 0 segLine.StartPoint.X = 0 segLine.StartPoint.Y = 0 segLine.StartPoint.Z = 0 segLine.EndPoint.X = 3 segLine.EndPoint.Y = 0 segLine.EndPoint.Z = 0 dblLong = 30 Set eleArc = CreateArcElement5(Nothing, segLine, dblLong, pntPlane) eleArc.Color = 3 If HasActiveModelReference Then Application.ActiveModelReference.AddElement eleArc eleArc.Redraw End If End Sub