第二个代码:
Dim ext As New Extents3d
Dim ed As Editor = AcadApp.DocumentManager.MdiActiveDocument.Editor Dim db As Database = AcadApp.DocumentManager.MdiActiveDocument.Database Using trans As Transaction = db.TransactionManager.StartTransaction() Dim btr As BlockTableRecord = trans.GetObject(db.CurrentSpaceId, OpenMode.ForRead) For Each id As ObjectId In btr Dim ent As Entity = trans.GetObject(id, OpenMode.ForRead, False) If Not ent Is Nothing Then ext.AddExtents(ent.GeometricExtents) End If Next End Using |