求助!!根据excel表格中的数据画多段线问题。
引用excel表格中的第一列数据画多段线,具体代码如下:Public Sub licheng()Dim excelApp As Excel.Application
Dim excelSheet As Excel.Worksheet
Dim strFile As String
strFile = ThisDrawing.Application.VBE.ActiveVBProject.fileName
Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = True
excelApp.Workbooks.Open Left$(strFile, Len(strFile) - Len("ex01.dvb")) & "\Excel\demo.xls"
Set excelSheet = excelApp.ActiveWorkbook.Sheets("Sheet1")
Dim i As Integer, j As Integer, k As Integer
For j = 1 To 9
For i = 1 To 9
Dim mspace As New clsModelSpace
Dim lichengzx As AcadLWPolyline
Dim lichengzxpoints(1 To 20) As Double
Dim b As Single, a As Single
b = excelSheet.Cells(1, 1).Value - 910
a = excelSheet.Cells(j, 1).Value - b
lichengzxpoints(i * 2 - 1) = a
lichengzxpoints(i * 2) = 245
Next i
Next j
Set lichengzx = mspace.AddLWPolyline(lichengzxpoints, True, 0)
ZoomAll
' 退出Excel应用程序
excelApp.Quit
End Sub
图框有固定的点位,里程标注线想弄成固定点位,起始点为(910,245),按我的想法,应该lichengzxpoints(1)=910,lichengzxpoints(2)=245,以此类推,但是运行程序后出现起始点(0,0)点,终点为(1620,245)的斜线,不知道哪里出错了。
Dim mspace As New clsModelSpace
Dim lichengzx As AcadLWPolyline
Dim lichengzxpoints(1 To 20) As Double
Dim b As Single, a As Single
应放在循环体之前
yshf 发表于 2011-11-7 23:04 static/image/common/back.gif
Dim mspace As New clsModelSpace
Dim lichengzx As AcadLWPolyline
谢谢,不过我放到循环体前面了,但是程序运行后还是老样子,是什么情况呢?
本帖最后由 yshf 于 2011-11-8 22:01 编辑
那九行到底是多少点的数据,按你的二层循环,得到的数据如下:
i=1j=1lichengzxpoints(1)=910
i=1j=1lichengzxpoints(2)=245
i=2j=1lichengzxpoints(3)=910
i=2j=1lichengzxpoints(4)=245
i=3j=1lichengzxpoints(5)=910
i=3j=1lichengzxpoints(6)=245
i=4j=1lichengzxpoints(7)=910
i=4j=1lichengzxpoints(8)=245
i=5j=1lichengzxpoints(9)=910
i=5j=1lichengzxpoints(10)=245
i=6j=1lichengzxpoints(11)=910
i=6j=1lichengzxpoints(12)=245
i=7j=1lichengzxpoints(13)=910
i=7j=1lichengzxpoints(14)=245
i=8j=1lichengzxpoints(15)=910
i=8j=1lichengzxpoints(16)=245
i=9j=1lichengzxpoints(17)=910
i=9j=1lichengzxpoints(18)=245
i=1j=2lichengzxpoints(1)=920
i=1j=2lichengzxpoints(2)=245
i=2j=2lichengzxpoints(3)=920
i=2j=2lichengzxpoints(4)=245
i=3j=2lichengzxpoints(5)=920
i=3j=2lichengzxpoints(6)=245
i=4j=2lichengzxpoints(7)=920
i=4j=2lichengzxpoints(8)=245
i=5j=2lichengzxpoints(9)=920
i=5j=2lichengzxpoints(10)=245
i=6j=2lichengzxpoints(11)=920
i=6j=2lichengzxpoints(12)=245
i=7j=2lichengzxpoints(13)=920
i=7j=2lichengzxpoints(14)=245
i=8j=2lichengzxpoints(15)=920
i=8j=2lichengzxpoints(16)=245
i=9j=2lichengzxpoints(17)=920
i=9j=2lichengzxpoints(18)=245
i=1j=3lichengzxpoints(1)=925
i=1j=3lichengzxpoints(2)=245
i=2j=3lichengzxpoints(3)=925
i=2j=3lichengzxpoints(4)=245
i=3j=3lichengzxpoints(5)=925
i=3j=3lichengzxpoints(6)=245
i=4j=3lichengzxpoints(7)=925
i=4j=3lichengzxpoints(8)=245
i=5j=3lichengzxpoints(9)=925
i=5j=3lichengzxpoints(10)=245
i=6j=3lichengzxpoints(11)=925
i=6j=3lichengzxpoints(12)=245
i=7j=3lichengzxpoints(13)=925
i=7j=3lichengzxpoints(14)=245
i=8j=3lichengzxpoints(15)=925
i=8j=3lichengzxpoints(16)=245
i=9j=3lichengzxpoints(17)=925
i=9j=3lichengzxpoints(18)=245
i=1j=4lichengzxpoints(1)=1031
i=1j=4lichengzxpoints(2)=245
i=2j=4lichengzxpoints(3)=1031
i=2j=4lichengzxpoints(4)=245
i=3j=4lichengzxpoints(5)=1031
i=3j=4lichengzxpoints(6)=245
i=4j=4lichengzxpoints(7)=1031
i=4j=4lichengzxpoints(8)=245
i=5j=4lichengzxpoints(9)=1031
i=5j=4lichengzxpoints(10)=245
i=6j=4lichengzxpoints(11)=1031
i=6j=4lichengzxpoints(12)=245
i=7j=4lichengzxpoints(13)=1031
i=7j=4lichengzxpoints(14)=245
i=8j=4lichengzxpoints(15)=1031
i=8j=4lichengzxpoints(16)=245
i=9j=4lichengzxpoints(17)=1031
i=9j=4lichengzxpoints(18)=245
i=1j=5lichengzxpoints(1)=1120
i=1j=5lichengzxpoints(2)=245
i=2j=5lichengzxpoints(3)=1120
i=2j=5lichengzxpoints(4)=245
i=3j=5lichengzxpoints(5)=1120
i=3j=5lichengzxpoints(6)=245
i=4j=5lichengzxpoints(7)=1120
i=4j=5lichengzxpoints(8)=245
i=5j=5lichengzxpoints(9)=1120
i=5j=5lichengzxpoints(10)=245
i=6j=5lichengzxpoints(11)=1120
i=6j=5lichengzxpoints(12)=245
i=7j=5lichengzxpoints(13)=1120
i=7j=5lichengzxpoints(14)=245
i=8j=5lichengzxpoints(15)=1120
i=8j=5lichengzxpoints(16)=245
i=9j=5lichengzxpoints(17)=1120
i=9j=5lichengzxpoints(18)=245
i=1j=6lichengzxpoints(1)=1328
i=1j=6lichengzxpoints(2)=245
i=2j=6lichengzxpoints(3)=1328
i=2j=6lichengzxpoints(4)=245
i=3j=6lichengzxpoints(5)=1328
i=3j=6lichengzxpoints(6)=245
i=4j=6lichengzxpoints(7)=1328
i=4j=6lichengzxpoints(8)=245
i=5j=6lichengzxpoints(9)=1328
i=5j=6lichengzxpoints(10)=245
i=6j=6lichengzxpoints(11)=1328
i=6j=6lichengzxpoints(12)=245
i=7j=6lichengzxpoints(13)=1328
i=7j=6lichengzxpoints(14)=245
i=8j=6lichengzxpoints(15)=1328
i=8j=6lichengzxpoints(16)=245
i=9j=6lichengzxpoints(17)=1328
i=9j=6lichengzxpoints(18)=245
i=1j=7lichengzxpoints(1)=1443
i=1j=7lichengzxpoints(2)=245
i=2j=7lichengzxpoints(3)=1443
i=2j=7lichengzxpoints(4)=245
i=3j=7lichengzxpoints(5)=1443
i=3j=7lichengzxpoints(6)=245
i=4j=7lichengzxpoints(7)=1443
i=4j=7lichengzxpoints(8)=245
i=5j=7lichengzxpoints(9)=1443
i=5j=7lichengzxpoints(10)=245
i=6j=7lichengzxpoints(11)=1443
i=6j=7lichengzxpoints(12)=245
i=7j=7lichengzxpoints(13)=1443
i=7j=7lichengzxpoints(14)=245
i=8j=7lichengzxpoints(15)=1443
i=8j=7lichengzxpoints(16)=245
i=9j=7lichengzxpoints(17)=1443
i=9j=7lichengzxpoints(18)=245
i=1j=8lichengzxpoints(1)=1522
i=1j=8lichengzxpoints(2)=245
i=2j=8lichengzxpoints(3)=1522
i=2j=8lichengzxpoints(4)=245
i=3j=8lichengzxpoints(5)=1522
i=3j=8lichengzxpoints(6)=245
i=4j=8lichengzxpoints(7)=1522
i=4j=8lichengzxpoints(8)=245
i=5j=8lichengzxpoints(9)=1522
i=5j=8lichengzxpoints(10)=245
i=6j=8lichengzxpoints(11)=1522
i=6j=8lichengzxpoints(12)=245
i=7j=8lichengzxpoints(13)=1522
i=7j=8lichengzxpoints(14)=245
i=8j=8lichengzxpoints(15)=1522
i=8j=8lichengzxpoints(16)=245
i=9j=8lichengzxpoints(17)=1522
i=9j=8lichengzxpoints(18)=245
i=1j=9lichengzxpoints(1)=1620
i=1j=9lichengzxpoints(2)=245
i=2j=9lichengzxpoints(3)=1620
i=2j=9lichengzxpoints(4)=245
i=3j=9lichengzxpoints(5)=1620
i=3j=9lichengzxpoints(6)=245
i=4j=9lichengzxpoints(7)=1620
i=4j=9lichengzxpoints(8)=245
i=5j=9lichengzxpoints(9)=1620
i=5j=9lichengzxpoints(10)=245
i=6j=9lichengzxpoints(11)=1620
i=6j=9lichengzxpoints(12)=245
i=7j=9lichengzxpoints(13)=1620
i=7j=9lichengzxpoints(14)=245
i=8j=9lichengzxpoints(15)=1620
i=8j=9lichengzxpoints(16)=245
i=9j=9lichengzxpoints(17)=1620
i=9j=9lichengzxpoints(18)=245
错在什么地方,你应该明白了。
yshf 发表于 2011-11-8 21:58 static/image/common/back.gif
那九行到底是多少点的数据,按你的二层循环,得到的数据如下:
i=1j=1lichengzxpoints(1)=910
i=1j ...
非常感谢,问题已得到解决。
页:
[1]