Dim excelapp As Object
Dim excelbook As Object
Dim excel As Object '定义读取的excel表
因为cad的vba 稍微比excel麻烦一些,所以最好在cad里面 *** 作完了,再向excel发送数据。
昨晚刚给别人写的,导入测量坐标画线形,然后节点上加个圈,简单的模板,希望能帮到你!
Option ExplicitSub pic()
Dim xls As Variant
Dim xlbk As Variant
Dim xlst As Variant
Dim arr As Variant
Dim i As Integer, lst As Integer
Dim p() As Double
Dim ac(0 To 2) As Double
Set xls = CreateObject("Excel.Application")
Set xlbk = xls.Workbooks.Open(ThisDrawing.path & "\data.xls")
xls.Visible = True
Set xlst = xlbk.Worksheets("data")
arr = xlst.usedrange
lst = UBound(arr, 1)
ReDim p(0 To lst * 2 - 1)
For i = 1 To lst
p(i * 2 - 2) = arr(i, 1)
p(i * 2 - 1) = arr(i, 2)
Next i
xls.Quit
ThisDrawing.ModelSpace.AddLightWeightPolyline (p)
For i = 2 To lst - 1
ac(0) = arr(i, 1): ac(1) = arr(i, 2): ac(2) = 0
ThisDrawing.ModelSpace.AddCircle ac, 2
Next i
ZoomExtents
ThisDrawing.Save
Set xlst = Nothing
Set xlbk = Nothing
Set xls = Nothing
End Sub
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)