- 积分
- 495
- 明经币
- 个
- 注册时间
- 2007-4-22
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2013-5-1 20:36:03
|
显示全部楼层
Dim oAJlayer As AcadLayer
Dim layercollection As AcadLayers
Dim PlineObj As Variant
Dim point1 As Variant
Dim point2(0 To 2) As Double
Dim point3(0 To 2) As Double
Dim dldm As String '定义地类代码
Dim dlmj As Double '定义水塘存储的面积变量
Dim getchar As String
Dim a As Integer
dlmj = 0: dlmj1 = 0: a = 0
Close #1
Open "c:\二调地类@815.txt" For Append As #1
Close #1
Kill "c:\二调地类@815.txt"
Close #2
Open "c:\二调地类面积统计@815.txt" For Append As #2
Close #2
Kill "c:\二调地类面积统计@815.txt"
getchar = ThisDrawing.Utility.GetString(3, "请输入要统计的地类代号:")
a = ThisDrawing.Utility.GetInteger("请输入视窗大小:")
Set sset = ThisDrawing.SelectionSets.Add(str(Int(Timer))) '用秒数,选择集不会重复
Dim ft1(0) As Integer
Dim fd1(0) As Variant
ft1(0) = 8
fd1(0) = "ZDH1"
sset.Select acSelectionSetAll, , , ft1, fd1
Set layercollection = ThisDrawing.Layers
Set oAJlayer = layercollection.Add(getchar & "地类统计")
ThisDrawing.ActiveLayer = oAJlayer '设置当前图层
ThisDrawing.ActiveLayer.color = acGreen '设置当前图层的颜色
For Each element In sset '在选择集中进行循环
If element.ObjectName = "AcDbText" Then '对文字的处理
dldm = Right(element.TextString, 3)
If dldm = getchar Then
point1 = element.InsertionPoint '得到块的插入点坐标
Dim spt As String
Dim spt1(0 To 2) As Double
Dim spt2(0 To 2) As Double
Dim s As Double
spt = point1(0) & "," & point1(1)
spt1(0) = point1(0) - a
spt1(1) = point1(1) + a
spt1(2) = 0
spt2(0) = point1(0) + a
spt2(1) = point1(1) - a
spt2(2) = 0
ZoomWindow spt1, spt2
'ZoomExtents
ThisDrawing.SendCommand Chr(3) & Chr(3) & "-boundary " & spt & " " & " "
ThisDrawing.SendCommand "draworder last f "
ThisDrawing.SendCommand "_.area o last "
ThisDrawing.SendCommand Chr(3) & Chr(3)
dlmj = ThisDrawing.GetVariable("AREA") + dlmj
element.color = acRed
End If
End If
Next
Open "c:\二调地类面积统计@815.txt" For Append As #2
Print #2, getchar; ":"; dlmj; "合:"; dlmj * 0.0015; "亩"
Close #2 |
|