求autocad vba高手写一个用鼠标选择图形中某条多段线,把所选择的多段线项点输出到EXCEL的代码!

希望能注释每句代码的意思!
2024-11-06 20:31:51
推荐回答(1个)
回答(1):

输出顶点坐标的格式是什么样的?
Sub a()
Dim retCoord() As Double
Dim a As AcadLWPolyline
Dim i As Integer
Dim Excel As Excel.Application
Dim ExcelSheet As Object
Dim ExcelWorkbook As Object
i = 0
ThisDrawing.Utility.GetEntity a, "Select an object"
retCoord() = a.Coordinates
Set Excel = New Excel.Application
Set ExcelWorkbook = Excel.Workbooks.Open("excel文件目录")
Set ExcelSheet = Excel.ActiveSheet
Excel.Visible = True
On Error GoTo e
Do While CBool(retCoord(i)) <> False
ExcelSheet.Cells(i + 1, 1).Value = retCoord(i)
i = i + 1
Loop
e: Exit Sub
End Sub