明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1499|回复: 1

求弧长标注

[复制链接]
发表于 2009-8-31 08:56:00 | 显示全部楼层 |阅读模式

已知直径和弧长画弧,并标注弧长。谢谢。

发表于 2009-8-31 09:03:00 | 显示全部楼层
本帖最后由 作者 于 2009-8-31 10:27:31 编辑

http://www.mjtd.com/Develop/ArticleShow.asp?ArticleID=666标注圆弧长度
  1. Sub DimArcLeng()
  2. Dim Arc As AcadArc
  3. Dim Pnt As Variant
  4. Err.Clear
  5. On Error Resume Next
  6. '选择圆弧
  7. ThisDrawing.Utility.GetEntity Arc, Pnt, "请选择圆弧:"
  8. If Err.Number <> 13 And Err.Number <> 0 Then Exit Sub
  9. Do Until Arc.ObjectName = "AcDbArc"
  10. Err.Clear
  11. ThisDrawing.Utility.GetEntity Arc, Pnt, "你所选的不是圆弧,请重新选择圆弧:"
  12. If Err.Number <> 13 And Err.Number <> 0 Then Exit Sub
  13. Loop
  14. '获取圆弧各属性
  15. Dim Leng As Double
  16. Dim SPnt As Variant
  17. Dim EPnt As Variant
  18. Dim CPnt As Variant
  19. Leng = Arc.ArcLength
  20. SPnt = Arc.StartPoint
  21. EPnt = Arc.EndPoint
  22. CPnt = Arc.Center
  23. '选择标注点
  24. Dim PntforDim As Variant
  25. PntforDim = ThisDrawing.Utility.GetPoint(, "选择标注点位置:")
  26. '对圆弧进行角度标注
  27. Dim DimAng As AcadDim3PointAngular
  28. Set DimAng = ThisDrawing.ModelSpace.AddDim3PointAngular(CPnt, SPnt, EPnt, PntforDim)
  29. '获取角度标注的精度控制(小数点位)
  30. Dim FormatDot As Integer
  31. Dim FormatTxt As String
  32. FormatDot = DimAng.TextPrecision
  33. '转换为精度控制格式
  34. FormatTxt = "0."
  35. Dim I As Integer
  36. For I = 0 To FormatDot
  37. If I > 0 Then
  38. FormatTxt = FormatTxt & "0"
  39. End If
  40. Next
  41. '更改角度标注的文字内容
  42. DimAng.TextOverride = Format(Leng, FormatTxt)
  43. End Sub
已知弧长和半径求圆弧角公式
ang = arcLen/Radius
程序如下:
  1. Sub llss()
  2.   Dim objArc As AcadArc
  3.   Dim pp(2) As Double
  4.   Dim Ang, startAng, endAng
  5.   Dim arcLen, Dia, Delta
  6.   arcLen = 2050: Dia = 1500: Delta = 16
  7.   Ang = (arcLen / (Dia / 2))
  8.   startAng = (Atn(1) * 4) * 1.5 - Ang / 2
  9.   endAng = startAng + Ang
  10.   '
  11.   With ThisDrawing.ModelSpace
  12.     Set objArc = .AddArc(pp, Dia / 2, startAng, endAng)
  13.     With objArc
  14.       Debug.Print .ArcLength
  15.     End With
  16.   End With
  17. End Sub
有时间,在此基础上再研究一下,在文字上方画弧的方法,而不是用arcLen=2050的方法.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 01:27 , Processed in 0.144716 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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