Dim acDoc As Autodesk.AutoCAD.ApplicationServices.Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim acDatabase As Database = acDoc.Database
Using (acDoc.LockDocument)
Using trans As Transaction = acDatabase.TransactionManager.StartTransaction
Dim bt As BlockTable = trans.GetObject(acDatabase.BlockTableId, OpenMode.ForWrite)
Dim btr As BlockTableRecord = trans.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForWrite)
For Each objId As ObjectId In btr
Dim ent As Entity = trans.GetObject(objId, OpenMode.ForWrite)