【hehaidizhi】绿 15:24:26
现网上收集了一个批量统计线段长度并导出excel的源码,但是不知道怎么写成cad中可以加载运行的文件,麻烦哪位大哥大姐帮帮忙,做成个可以直接加载的文件吧,谢谢了
Sub GetLenth()
Dim ExcelApp As New Excel.Application
Dim ExcelWkbk As Excel.Workbook
Set ExcelWkbk = ExcelApp.Workbooks.Add
Dim i As Integer
i = 1
Dim Ent As AcadEntity
Dim pt1 As Variant, pt2 As Variant
With ExcelWkbk.Worksheets("sheet1")
For Each Ent In ThisDrawing.ModelSpace
If Ent.ObjectName = "AcDbLine" Then
.Range("A" & i) = i
.Range("B" & i) = Ent.Length
i = i + 1
End If
Next Ent
End With
ExcelApp.ActiveWorkbook.SaveAs "d:AcadLen.xls"
ExcelApp.Workbooks.Close
ExcelApp.Quit
End Sub |