Ravn
Civil/Environmental
- Nov 22, 2005
- 8
1) a row from a text file is read with the "Line input" command
2) some information is picked up from that row with "Mid" (coordinates X,Y,Z and an index number)
3) index number indicates whether this point is a single point or a part of line,
so there are to Cases how to continue from this phase
4) if the point is a member of a line, other points (amount is unknown so far) must also be read from the file (=next rows).
So.. X,Y,Z already read from the line must be stored before reading a new row from the file, which contain another coordinates. Then the next row is read and if the index number tells this row is still a part of the same line (if there are rows for lines in the file, there are always at least two points for a line and points for a line are always one row after another row).
After all the points (X,Y,Z) are received, an array should be made of this points (dbl3DPolylineVertices(0 to n) and then draw a line in AutoCAD.
My problem is, that I can't make an array from these points I read from my text file. I have "Subscript out of range" as a value for my dbl3DPolylineVertices(intVertexCounter + n) variables. How does this thing work?
Best regards,
Ravn.
' case for a line begins
Case Else
strCurrentIndexNumber = strIndexNumber
' stores the points from the already read row
dbl3DPolylineVertices(0) = Mid(strLine1, 33, 14)
dbl3DPolylineVertices(1) = Mid(strLine1, 47, 14)
dbl3DPolylineVertices(2) = Mid(strLine1, 61, 14)
' begins a loop, which goes as long as the last row imported from the file has got a different index number
Do Until strIndexNumber <> strCurrentIndexNumber
intVertexCounter = 3
Line Input #1, strLine1
strBreaklineNumber = LTrim(Mid(strLine1, 9, 8))
ReDim Preserve dbl3DPolylineVertices(0 To intVertexCounter + 2)
dbl3DPolylineVertices(intVertexCounter) = Mid(strLine1, 33, 14)
dbl3DPolylineVertices(intVertexCounter + 1) = Mid(strLine1, 47, 14)
dbl3DPolylineVertices(intVertexCounter + 2) = Mid(strLine1, 61, 14)
' changes the intVertexCounter for upcoming coordinates/points
intVertexCounter = intVertexCounter + 3
Loop
' now i know how many vertices there are in my line, so i can define the dimension for array
' it was first defined as "Dim dbl3DPolylineVertices() as Double"
ReDim Preserve dbl3DPolylineVertices(0 To intVertexCounter - 3)
' SHOULD draw the line in AutoCAD, containing the array made above
Set ent3DPolyline = ThisDrawing.ModelSpace.Add3DPoly(dbl3DPolylineVertices)
2) some information is picked up from that row with "Mid" (coordinates X,Y,Z and an index number)
3) index number indicates whether this point is a single point or a part of line,
so there are to Cases how to continue from this phase
4) if the point is a member of a line, other points (amount is unknown so far) must also be read from the file (=next rows).
So.. X,Y,Z already read from the line must be stored before reading a new row from the file, which contain another coordinates. Then the next row is read and if the index number tells this row is still a part of the same line (if there are rows for lines in the file, there are always at least two points for a line and points for a line are always one row after another row).
After all the points (X,Y,Z) are received, an array should be made of this points (dbl3DPolylineVertices(0 to n) and then draw a line in AutoCAD.
My problem is, that I can't make an array from these points I read from my text file. I have "Subscript out of range" as a value for my dbl3DPolylineVertices(intVertexCounter + n) variables. How does this thing work?
Best regards,
Ravn.
' case for a line begins
Case Else
strCurrentIndexNumber = strIndexNumber
' stores the points from the already read row
dbl3DPolylineVertices(0) = Mid(strLine1, 33, 14)
dbl3DPolylineVertices(1) = Mid(strLine1, 47, 14)
dbl3DPolylineVertices(2) = Mid(strLine1, 61, 14)
' begins a loop, which goes as long as the last row imported from the file has got a different index number
Do Until strIndexNumber <> strCurrentIndexNumber
intVertexCounter = 3
Line Input #1, strLine1
strBreaklineNumber = LTrim(Mid(strLine1, 9, 8))
ReDim Preserve dbl3DPolylineVertices(0 To intVertexCounter + 2)
dbl3DPolylineVertices(intVertexCounter) = Mid(strLine1, 33, 14)
dbl3DPolylineVertices(intVertexCounter + 1) = Mid(strLine1, 47, 14)
dbl3DPolylineVertices(intVertexCounter + 2) = Mid(strLine1, 61, 14)
' changes the intVertexCounter for upcoming coordinates/points
intVertexCounter = intVertexCounter + 3
Loop
' now i know how many vertices there are in my line, so i can define the dimension for array
' it was first defined as "Dim dbl3DPolylineVertices() as Double"
ReDim Preserve dbl3DPolylineVertices(0 To intVertexCounter - 3)
' SHOULD draw the line in AutoCAD, containing the array made above
Set ent3DPolyline = ThisDrawing.ModelSpace.Add3DPoly(dbl3DPolylineVertices)