excelVBA 让Excel里面的坐标自动在AutoCAD绘制多段线。

2024-11-20 16:37:39
推荐回答(1个)
回答1:

Sub kkk()
Dim acadApp As AcadApplication
Dim acaddocs As AcadDocuments
Dim acaddoc As AcadDocument
On Error Resume Next
Set acadApp = CreateObject("AutoCAD.Application")
Set acaddoc = acadApp.ActiveDocument
acadApp.Visible = True
Dim myline As AcadLWPolyline
Dim mylist(5) As Double
mylist(0) = Cells(1, 1)
mylist(1) = Cells(1, 2)
mylist(2) = Cells(2, 1)
mylist(3) = Cells(2, 2)
mylist(4) = Cells(3, 1)
mylist(5) = Cells(3, 2)
Set myline = acaddoc.ModelSpace.AddLightWeightPolyline(mylist)
End Sub