CAD设计论坛

 找回密码
 立即注册
论坛新手常用操作帮助系统等待验证的用户请看获取社区币方法的说明新注册会员必读(必修)
查看: 2885|回复: 0

[开发] 已知圆心角、弧长,VBA绘圆弧

[复制链接]
发表于 2009-6-10 08:42 | 显示全部楼层 |阅读模式
Sub AddArcLength()1 W  v, R, W" u1 v
    ' This example creates an arc in model space.
# J3 q0 d3 P; F    ' 已知圆心角、弧长绘弧
' F6 P' q$ S; @% d2 w    Dim arcObj As AcadArc5 R9 v" T# G# H* \
    Dim centerPoint As Variant
4 d) W  a$ i5 m; T; J: b    Dim radius As Double2 w* @5 H  E; q3 a
    Dim startAngleInRadian As Double
+ D, Z; S' Q# D4 r7 {3 M    Dim endAngleInRadian As Double
! U4 l% u: H+ u" [% a    Dim ARCLength As Double! |6 K) t' u9 x4 a+ I1 ^
    Dim lineobj As AcadLine& j$ z+ A% C/ g: X9 f- E1 y) H
    Dim getobj As ACADObject1 j# b; V. I( b& T1 F# q
    Dim p As Variant
+ A& X, O: P* \$ k6 m! e& A    $ b& C9 x9 ^, Z1 @4 U
    'centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#; L4 Q3 H+ F6 p% e& ]  j* r
    centerPoint = ThisDrawing.Utility.GetPoint(, "请指定圆心:")
' D4 ?  N$ u7 {    ThisDrawing.Utility.GetEntity getobj, p, "选择第一条直线:"
. g1 r8 ]8 T9 }' M! t& h    startAngleInRadian = getobj.Angle
  E" u5 k! }3 m) C0 R8 }    ThisDrawing.Utility.GetEntity getobj, p, "选择第二条直线:"1 ^) c* {7 ~/ R2 }( C4 W0 _
    endAngleInRadian = getobj.Angle/ i' V) s! S: o2 _+ {, r( I
    ARCLength = ThisDrawing.Utility.GetString(0, vbCrLf & "所绘弧长:")
9 n5 L5 r" O) `% e+ f    radius = ARCLength / (endAngleInRadian - startAngleInRadian)( n, Z6 V& m/ H
   
6 }; ?' s2 L! V- \/ @4 b1 q) z    ' Create the arc object in model space  ^* U& M1 I3 O, G$ q, s
    Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)
3 L5 ?# z& p$ _6 z'    ZoomAll; q0 `2 u& E1 Y$ @
End Sub
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关于|免责|隐私|版权|广告|联系|手机版|CAD设计论坛

GMT+8, 2024-11-27 09:54

CAD设计论坛,为工程师增加动力。

© 2005-2024 askcad.com. All rights reserved.

快速回复 返回顶部 返回列表