- 积分
- 10513
- 明经币
- 个
- 注册时间
- 2002-6-3
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2004-5-15 11:58:00
|
显示全部楼层
- Sub Test()
- Dim pt1 As Variant
- Dim pt2 As Variant
- Dim pt3 As Variant
- pt1 = ThisDrawing.Utility.GetPoint(, "指定圆弧的起点: ")
- pt2 = ThisDrawing.Utility.GetPoint(, "指定圆弧的第二个点: ")
- pt3 = ThisDrawing.Utility.GetPoint(, "指定圆弧的端点:: ")
- Const PI = 3.1415926
- ' 第一段角度
- Dim ang As Double
- ang = ThisDrawing.Utility.AngleFromXAxis(pt1, pt2)
- ' 第一段中点
- Dim spt(0 To 2) As Double
- spt(0) = (pt1(0) + pt2(0)) / 2
- spt(1) = (pt1(1) + pt2(1)) / 2
- Dim ept As Variant
- ept = ThisDrawing.Utility.PolarPoint(spt, ang - PI / 2, 1000)
- ' 第一段垂直平分线
- Dim LineObj1 As AcadLine
- Set LineObj1 = ThisDrawing.ModelSpace.AddLine(spt, ept)
- ' 第二段角度
- ang = ThisDrawing.Utility.AngleFromXAxis(pt3, pt2)
- ' 第二段中点
- spt(0) = (pt3(0) + pt2(0)) / 2
- spt(1) = (pt3(1) + pt2(1)) / 2
- ept = ThisDrawing.Utility.PolarPoint(spt, ang + PI / 2, 1000)
- ' 第二段垂直平分线
- Dim LineObj2 As AcadLine
- Set LineObj2 = ThisDrawing.ModelSpace.AddLine(spt, ept)
- ' 求交点,即为圆心
- Dim cpt As Variant
- cpt = LineObj1.IntersectWith(LineObj2, acExtendBoth)
- LineObj1.Delete
- LineObj2.Delete
- ' 求圆心与端点的距离,即为半径
- Dim r As Double
- r = Sqr((cpt(0) - pt1(0)) ^ 2 + (cpt(1) - pt1(1)) ^ 2)
- ' 求起始角度和终止角度
- Dim sang As Double
- sang = ThisDrawing.Utility.AngleFromXAxis(cpt, pt1)
- Dim eang As Double
- eang = ThisDrawing.Utility.AngleFromXAxis(cpt, pt3)
- If sang > eang Then
- sang = ThisDrawing.Utility.AngleFromXAxis(cpt, pt3)
- eang = ThisDrawing.Utility.AngleFromXAxis(cpt, pt1)
- End If
- ThisDrawing.ModelSpace.AddArc cpt, r, sang, eang
- End Sub
|
|