VBnet 返回指定块的实体id

 

        ''' <summary>
        ''' 返回指定块名的实体id
        ''' </summary>
        ''' <param name="db">数据库对象</param>
        ''' <param name="blockName">块名</param>
        ''' <returns>返回指定块名的实体id</returns>
        <Extension()>
        Function GetBlockObjectId(ByVal db As Database, ByVal blockName As String) As List(Of ObjectId)
            Dim ObjectIds As List(Of ObjectId) = New List(Of ObjectId)()
            Using trans As Transaction = db.TransactionManager.StartTransaction()
                Dim bt As BlockTable = CType(trans.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
                If Not bt.Has(blockName) Then Return ObjectIds
                Dim btr As BlockTableRecord = CType(bt(blockName).GetObject(OpenMode.ForRead), BlockTableRecord)
                Dim enumerator As BlockTableRecordEnumerator = btr.GetEnumerator()

                While enumerator.MoveNext()
                    ObjectIds.Add(enumerator.Current)
                End While

                trans.Commit()
            End Using
            Return ObjectIds
        End Function

上一篇:Oracle根据符合条件的数据循环批量更新


下一篇:mysql免安装版初次使用