Cad vba——导出桩号和标注距离并标面积

Public Function creatsel() As AcadSelectionSet
On Error Resume Next
Dim mys As String
mys = "mys"
Dim sel As AcadSelectionSet
   If Not IsNull(ThisDrawing.SelectionSets.Item(mys)) Then
       Set creatsel = ThisDrawing.SelectionSets.Item(mys)
       creatsel.Delete
    End If
Set creatsel = ThisDrawing.SelectionSets.Add(mys)
End Function
Sub 横断面桩号()
'On Error GoTo erro
Dim textlayer As AcadLayer
Dim dimlayer As AcadLayer
Dim sel As AcadSelectionSet
Dim txtfile As String
Dim mypt As Variant
txtfile = "C:\Users\Administrator\Desktop\坐标点.txt"
Open txtfile For Append As #1
Do
    Set sel = creatsel()
    sel.SelectOnScreen
    If sel.Count = 0 Then GoTo erro
    For i = 0 To sel.Count - 1
    If InStr(1, sel.Item(i).ObjectName, "text", vbTextCompare) > 0 Then
         If sel.Item(i).Layer = "横断面桩号" Then
             Print #1, sel.Item(i).TextString
         End If
    End If
    If InStr(1, sel.Item(i).ObjectName, "dime", vbTextCompare) > 0 Then
         If sel.Item(i).Layer = "0" Then
             Print #1, Format(sel.Item(i).Measurement, "0.00")
         End If
    End If
    
    If InStr(1, sel.Item(i).ObjectName, "lyline", vbTextCompare) > 0 Then
If sel.Item(i).Closed = True Then
    mypt = sel.Item(i).Coordinate(0)
    Dim mypt3(2) As Double
    mypt3(0) = mypt(0):    mypt3(1) = mypt(1):    mypt3(2) = 0
 Set txt = ThisDrawing.ModelSpace.AddText(Format(sel.Item(i).Area, "0.00"), mypt3, 3)
         If sel.Item(i).Layer = "滩地挖方" Then
             Print #1, Format(sel.Item(i).Area, "0.00")
         End If
         End If
    End If
    Next i
Loop

erro:
Close

MsgBox "OK    CAD二次开发qq:443440204", , "版权qq443440204"
End Sub

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山水CAD插件定制

你的鼓励是我创作最大的动力!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值