明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 5319|回复: 9

[VB]弧长自动标注

[复制链接]
发表于 2004-9-13 17:50 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 2004-9-13 20:05:32 编辑

运用圆弧的4个属性,弧长、起点、中点、终点,通过改变3点法标注圆弧角度对象的TextOverride属性值,用
弧长值代替角度值来实现弧长的自动标注。
  1. Public AcadUtil As Object
  2. Public Mospace As Object
  3. Public AcadDoc As Object
  4. Dim acadApp As AcadApplicationPrivate Sub fcbz_Click()
  5. Dim Arc As AcadArc
  6. Dim BasePnt As Variant
  7. Dim returnObj As AcadEntity
  8. Err.Clear
  9. On Error Resume Next'选择圆弧
  10. AcadUtil.GetEntity returnObj, BasePnt, "选择需标注的圆弧:"
  11. returnObj.color = acRed
  12. returnObj.UpdateDo Until returnObj.ObjectName = "AcDbArc"       Err.Clear
  13.       
  14.        MsgBox "你选择的对象是:" & returnObj.EntityName & "请继续选择", , "圆弧标注"
  15.        returnObj.coloc = rcByLayer
  16.        returnObj.Update
  17.       
  18.        AcadUtil.GetEntity returnObj, BasePnt, "选择需标注的圆弧:"
  19.        returnObj.color = acRed
  20.        returnObj.Update
  21. Loop'获取圆弧的属性
  22. Dim Leng As Double
  23. Dim Spnt As Variant
  24. Dim Epet As Variant
  25. Dim Cpnt As VariantLeng = returnObj.ArcLength
  26. Spnt = returnObj.StartPoint
  27. Epnt = returnObj.EndPoint
  28. Cpnt = returnObj.Center'选择标注位置
  29. Dim PentforDim As VariantPentforDim = AcadUtil.GetPoint(, "选择标注位置:")'对圆弧进行角度标注
  30. Dim dimAng As AcadDim3PointAngular
  31. Set dimAng = Mospace.AddDim3PointAngular(Cpnt, Spnt, Epnt, PentforDim)
  32. dimAng.TextHeight = 2'更改角度标注的文字为弧长
  33. dimAng.TextOverride = Format(Leng, "0.000")
  34. returnObj.coloc = rcByLayer
  35. returnObj.Update
  36. Set acadApp = Nothing
  37. Set aAcadDoc = Nothing
  38. End Sub'连接cad
  39. Private Sub Form_Load()
  40. On Error Resume Next
  41. Set acadApp = GetObject(, "AutoCAD.Application")
  42. If Err Then
  43.      Err.Clear
  44.      Set acadApp = CreateObject("AutoCAD.Application")
  45. End If
  46. Set AcadDoc = acadApp.ActiveDocument
  47. Set Mospace = AcadDoc.ModelSpace
  48. Set AcadUtil = AcadDoc.Utility
  49. acadApp.Visible = acTrue
  50. End Sub  
发表于 2005-3-27 22:15 | 显示全部楼层
是张帆的《VBA开发精彩实例里的吗》里的吗?
发表于 2005-4-20 18:42 | 显示全部楼层
能否教在下一下,这个程序经过怎么样的操作才能在CAD里应用?要不然您就直接发一个加载就能用的程序得了?


我的邮箱是


lzws03@163.com
发表于 2005-7-19 22:41 | 显示全部楼层

弧长标注的命令的什么呀

 

发表于 2008-4-5 22:12 | 显示全部楼层

AcadUtil.GetEntity returnObj, BasePnt, "选择需标注的圆弧:"

学习这段语句

发表于 2010-6-9 16:56 | 显示全部楼层

很感谢楼主分享,学习学习.

发表于 2011-12-10 23:08 | 显示全部楼层
vb看不懂啊
发表于 2011-12-10 23:36 | 显示全部楼层
收下,谢谢分享
发表于 2011-12-10 23:58 | 显示全部楼层
收下,谢谢分享
发表于 2011-12-11 08:20 | 显示全部楼层
好长的源码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-16 14:36 , Processed in 0.241148 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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