用Recordset管理实体数据
本帖最后由 作者 于 2008-5-28 15:16:10 编辑Sub gggg()
Dim Ent As AcadEntity, tt As AcadText
Dim adoRecordset As ADODB.Recordset
Set adoRecordset = New ADODB.Recordset
aa = Array("EntityText", "X", "Y", "Z"): bb = Array(adBSTR, adDouble, adDouble, adDouble)
With adoRecordset
For i = 0 To 3 '为Recordset2个字段,即为DataGrid添加2列
.Fields.Append aa(i), adVariant, , adFldMayBeNull
.Fields.Item(i).Type = bb(i)
Next i
.Open
For Each Ent In ThisDrawing.ModelSpace
Select Case Ent.ObjectName
Case "AcDbText"
Set tt = Ent
If tt.Layer = "零件表格文本" Then
.AddNew
.Fields(1).Value = Round(tt.InsertionPoint(0), 2)
.Fields(2) = Round(tt.InsertionPoint(1), 2)
.Fields(3) = 0
.Fields(0) = tt.TextString
End If
End Select
Next Ent
.Sort = y
.MoveFirst
For ii = 0 To .RecordCount - 1
Debug.Print .Fields(0).Value, .Fields(1).Value; .Fields(2).Value
.MoveNext
Next ii
End With
End Sub
赞一个
页:
[1]