cad. vb代码!不知道怎么用!小弟愚钝,希望能讲解
:朋友给的自动读取电子表格坐标画cad图的代码!就是不知道怎么使用的!请教下大家Subexcelspl()DimplineObjAsAcadLWPolylineDimat...
:朋友给的自动读取电子表格坐标画cad图的代码!就是不知道怎么使用的!请教下大家
Sub excelspl()
Dim plineObj As AcadLWPolyline Dim attrtxt0 As String
Dim attrtxt1 As String
Dim corow As Long
Dim p Set excelapp = CreateObject("excel.application") '激活excel程序 excelapp.Workbooks.Open (ThisDrawing.Path&"/data.xls") '打开工作薄,同CAD文件一个目录 ThisDrawing.pathSet excelsheet = excelapp.ActiveWorkbook.Sheets("sheet1") '当前工作表为sheet1 corow = excelsheet.UsedRange.Rows.Count '计算工作表的总行数 ReDim p(0 To (corow * 2 - 1)) As Double '定义点坐标 For i = 1 To corow attrtxt0 = excelsheet.Cells(i, 1).Value 'X坐标 attrtxt1 = excelsheet.Cells(i, 2).Value 'Y坐标 p((i - 1) * 2) = Val(attrtxt0) p((i - 1) * 2 + 1) = Val(attrtxt1) Next i Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(p) '画多义线End Sub 展开
Sub excelspl()
Dim plineObj As AcadLWPolyline Dim attrtxt0 As String
Dim attrtxt1 As String
Dim corow As Long
Dim p Set excelapp = CreateObject("excel.application") '激活excel程序 excelapp.Workbooks.Open (ThisDrawing.Path&"/data.xls") '打开工作薄,同CAD文件一个目录 ThisDrawing.pathSet excelsheet = excelapp.ActiveWorkbook.Sheets("sheet1") '当前工作表为sheet1 corow = excelsheet.UsedRange.Rows.Count '计算工作表的总行数 ReDim p(0 To (corow * 2 - 1)) As Double '定义点坐标 For i = 1 To corow attrtxt0 = excelsheet.Cells(i, 1).Value 'X坐标 attrtxt1 = excelsheet.Cells(i, 2).Value 'Y坐标 p((i - 1) * 2) = Val(attrtxt0) p((i - 1) * 2 + 1) = Val(attrtxt1) Next i Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(p) '画多义线End Sub 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询