检索所有 DBText 的所有 dxf 值

Retrieving all dxf values for all DBText

我正在尝试获取当前打开绘图中每个 DBText 值的图层、位置、值、高度、宽度和样式。到目前为止,我只能得到 objectIDs。

Function SelectAllText(dbIn As Database) As ObjectIdCollection
    Using doclock = Application.DocumentManager.MdiActiveDocument.LockDocument
        Dim retIDs As New ObjectIdCollection
        Using tr As Transaction = dbIn.TransactionManager.StartTransaction
            Dim bt As BlockTable = dbIn.BlockTableId.GetObject(OpenMode.ForRead)
            For Each btrID As ObjectId In bt
                Dim btr As BlockTableRecord = TryCast(tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead), BlockTableRecord)
                For Each TRefID As ObjectId In btr
                    Dim te = TryCast(tr.GetObject(TRefID, OpenMode.ForRead), DBText),
                        tid = te.ObjectId
                    retIDs.Add(tid)
                Next
            Next
        End Using
        Return retIDs
    End Using
End Function

您提出的方法应该有效,基本上以相同的方式:遍历数据库>BlockTable>BlockTableRecord(ModelSpace)>All Entities。

使用每个 DBText 的 ObjectId,您可以:

Dim acText as DBText = tr.GetObject(dbTextId, OpenMode.ForRead)
Dim positionPoint as Point3d = acText.Position
Dim height as Double = acText.Height
Dim content as String = acText.TextString