- 积分
- 252
- 明经币
- 个
- 注册时间
- 2003-6-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2003-6-20 10:18:00
|
显示全部楼层
re
Option Explicit
Private Sub CommandButton1_Click()
Dim totalczx As Integer
Dim czx, spx As Integer
Dim textobj As AcadEntity
Dim point1 As Variant
Dim point2 As Variant
Dim a(1 To 10000, 0 To 2) As Double
Dim b(1 To 10000, 0 To 2) As Double
Dim i, j As Integer
i = 1
j = 1
czx = 0
Open "e:\1.txt" For Output As #1 '
For Each textobj In ThisDrawing.ModelSpace '找字
If textobj.ObjectName = "AcDbText" Then
point1 = textobj.InsertionPoint
a(i, 0) = point1(0)
a(i, 1) = point1(1)
b(i, 0) = point1(0)
b(i, 1) = point1(1)
i = i + 1
j = j + 1
czx = czx + 1
Write #1, czx, point1(0), point1(1), point1(2)
End If
Next
totalczx = czx
Close #1
'############################首先按x坐标排序####################################333
Dim im As Integer
Dim t As Variant
Dim n As Integer
n = totalczx
For i = 1 To n - 1 '排序
im = i
For j = i + 1 To n
If a(j, 0) < a(im, 0) Then im = j
Next j
t = a(i, 0)
a(i, 0) = a(im, 0)
a(im, 0) = t
Next i
For i = 1 To czx
Next i
czx = 0
Open "e:\字的排序按x坐标.txt" For Output As #3
For i = 1 To totalczx
czx = czx + 1
Write #3, czx, a(i, 0), a(i, 1), a(i, 2)
Next i
Close #3
'######################然后按y坐标排序########################333
n = totalczx '假设水平线的数目为100
For i = 1 To n - 1 '排序
im = i
For j = i + 1 To n
If b(j, 1) < b(im, 1) Then im = j
Next j
t = b(i, 1)
b(i, 1) = b(im, 1)
b(im, 1) = t
Next i
For i = 1 To czx
Next i
czx = 0
Open "e:\字的排序按y坐标排序.txt" For Output As #4
For i = 1 To totalczx
czx = czx + 1
Write #4, czx, b(i, 0), b(i, 1), b(i, 2)
Next i
Close #4
End Sub |
|