luxifa 发表于 2010-9-4 17:26:00

已知圆弧起点终点半径,用VBA怎么画圆弧

<p>在算圆心和起始终止弧度的时候老是出现问题,有的圆弧能画有的圆弧不能画,请问有什么方法计算起来简单点</p>

woaishuijia 发表于 2010-9-5 18:54:00

Sub A()
Dim StartPoint As Variant, EndPoint As Variant, Radius As Double
Dim Circle1 As AcadCircle, Circle2 As AcadCircle, V As Variant, Center(2) As Double
Dim ActiveSpace As AcadBlock

On Error GoTo 10

With ThisDrawing
StartPoint = .Utility.GetPoint(, vbCrLf & "指定圆弧起点:")
EndPoint = .Utility.GetPoint(StartPoint, "指定圆弧端点:")
Radius = .Utility.GetDistance(EndPoint, "指定圆弧半径:")

Set Circle1 = .ModelSpace.AddCircle(StartPoint, Radius)
Set Circle2 = .ModelSpace.AddCircle(EndPoint, Radius)
V = Circle1.IntersectWith(Circle2, acExtendNone)

Circle1.Delete
Circle2.Delete

If UBound(V) = -1 Then
.Utility.Prompt "圆弧半径太小,无效!"
Else
Center(0) = V(0): Center(1) = V(1): Center(2) = V(2)
If .ActiveSpace = acModelSpace Then
Set ActiveSpace = .ModelSpace
Else
Set ActiveSpace = .PaperSpace
End If
ActiveSpace.AddArc Center, Radius, .Utility.AngleFromXAxis(Center, StartPoint), .Utility.AngleFromXAxis(Center, EndPoint)
End If
End With
10: End Sub

hwang21 发表于 2010-9-7 22:56:00

另一种思路:判断Start point 与radius 和 end point 与radius 的距离是否相等,相等就addarc 否则提示弧不存在。

wxld599 发表于 2010-10-9 20:39:00

把圆心的坐标解出来就可以了哇
页: [1]
查看完整版本: 已知圆弧起点终点半径,用VBA怎么画圆弧