mikewolf2k 发表于 2016-4-27 14:51
把aa里面的代码放到取点程序最后面。
这是我重新写的,就是想用这些点的最大最小值做一个方格网,但还是不对,不知道错在哪里- Dim L As Integer
- Dim H(10000) As Double, X(10000) As Double, Y(10000) As Double, Z(10000) As Double
- Dim Xmax As Double, Xmin As Double, Ymax As Double, Ymin As Double
- Sub txt_read()
- Dim txtname As String
- Dim L As Integer
- Dim plineObj As AcadLWPolyline
- Dim points(0 To 11) As Double
- Dim M As Integer '行数
- Dim N As Integer '列数
- Dim Dx As Double '每个网格x值
- Dim Dy As Double '每个网格y值
- ' 定义多段线的点
-
- L = 0 '初始值
- Open "E:\demdata.txt" For Input As #1 '打开文件
- Xmax = X(0): Xmin = X(0)
- Ymax = Y(0): Ymin = Y(0)
- Do While Not EOF(1) '文件读取循环
- If X(L) >= Xmax Then
- Xmax = X(L)
- End If
- If Y(L) >= Ymax Then
- Ymax = Y(L)
- End If
- If X(L) <= Xmin Then
- Xmin = X(L)
- End If
- If Y(L) <= Ymin Then
- Ymin = Y(L)
- End If
- L = L + 1 '个数加1
- Input #1, H(L), X(L), Y(L), Z(L) '读取文件数据, H贮存点序号,XYZ为坐标
- Loop '文件读取循环
- Close #1 '关闭文件
-
- Dx = 14.5
- Dy = 15.6
- M = (Xmax - Xmin) / Dx '求出行数
- N = (Ymax - Ymin) / Dy '求出列数
- points(0) = Xmin: points(1) = Ymin: points(2) = 0
- points(3) = Xmin: points(4) = Ymax: points(5) = 0
- points(6) = Xmax: points(7) = Ymax: points(8) = 0
- points(9) = Xmax: points(10) = Ymin: points(11) = 0
- '在模型空间中创建一个多段线对象
- Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
- ZoomAll
- End Sub
|