土木在线论坛 \ 建筑设计 \ CAD下载及教程 \ [vb]弧长自动标注程序

[vb]弧长自动标注程序

发布于:2004-09-13 20:06:13 来自:建筑设计/CAD下载及教程 [复制转发]
运用圆弧的4个属性,弧长、起点、中点、终点,通过改变3点法标注圆弧角度对象的TextOverride属性值,用弧长值代替角度值来实现弧长的自动标注。


Public AcadUtil As Object
Public Mospace As Object
Public AcadDoc As Object
Dim acadApp As AcadApplication

Private Sub fcbz_Click()
Dim Arc As AcadArc
Dim BasePnt As Variant
Dim returnObj As AcadEntity
Err.Clear
On Error Resume Next

’选择圆弧
AcadUtil.GetEntity returnObj, BasePnt, "选择需标注的圆弧:"
returnObj.color = acRed
returnObj.Update

Do Until returnObj.ObjectName = "AcDbArc"

Err.Clear

MsgBox "你选择的对象是:" & returnObj.EntityName & "请继续选择", , "圆弧标注"
returnObj.coloc = rcByLayer
returnObj.Update

AcadUtil.GetEntity returnObj, BasePnt, "选择需标注的圆弧:"
returnObj.color = acRed
returnObj.Update
Loop

’获取圆弧的属性
Dim Leng As Double
Dim Spnt As Variant
Dim Epet As Variant
Dim Cpnt As Variant

Leng = returnObj.ArcLength
Spnt = returnObj.StartPoint
Epnt = returnObj.EndPoint
Cpnt = returnObj.Center

’选择标注位置
Dim PentforDim As Variant

PentforDim = AcadUtil.GetPoint(, "选择标注位置:")

’对圆弧进行角度标注
Dim dimAng As AcadDim3PointAngular
Set dimAng = Mospace.AddDim3PointAngular(Cpnt, Spnt, Epnt, PentforDim)
dimAng.TextHeight = 2

’更改角度标注的文字为弧长
dimAng.TextOverride = Format(Leng, "0.000")
returnObj.coloc = rcByLayer
returnObj.Update
Set acadApp = Nothing
Set aAcadDoc = Nothing
End Sub





’连接cad
Private Sub Form_Load()
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Err.Clear
Set acadApp = CreateObject("AutoCAD.Application")
End If
Set AcadDoc = acadApp.ActiveDocument
Set Mospace = AcadDoc.ModelSpace
Set AcadUtil = AcadDoc.Utility
acadApp.Visible = acTrue
End Sub

全部回复(10 )

只看楼主 我来说两句
  • deewg
    deewg 沙发
    这个东西还是要好好的看看
    2006-01-24 23:47:24

    回复 举报
    赞同0
  • yfy2003
    yfy2003 板凳
    是啊!2006里有了!很方便了!但2006以下就没有了哦!
    2006-01-23 13:50:23

    回复 举报
    赞同0
加载更多
这个家伙什么也没有留下。。。

CAD下载及教程

返回版块

52.08 万条内容 · 665 人订阅

猜你喜欢

阅读下一篇

ZDM渠堤纵断面中桩号有时出现小数无法解决

各位ZDM高手,在下想请教一下,在ZDM中生成渠道纵断面图时,桩号中有小数,生成图时横栏里桩号却全是整数,请问该如何解决?

回帖成功

经验值 +10