Message 1 of 4
Exploding all blocks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am using this code. It produces no errors but does not explode the blocks in the drawing. WShat am I missing
Try
Dim objs As DBObjectCollection = New DBObjectCollection()
Using lk As DocumentLock = doc.LockDocument()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = TryCast(tr.GetObject(db.BlockTableId, OpenMode.ForRead), BlockTable)
Dim modelBtr As BlockTableRecord = tr.GetObject(bt(BlockTableRecord.ModelSpace), OpenMode.ForRead)
For Each id As ObjectId In modelBtr
If id.ObjectClass.Name = "AcDbBlockReference" Then
Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForRead, False), Entity)
ent.Explode(objs)
ent.UpgradeOpen()
ent.Erase()
End If
Next
tr.Commit()
End Using
End Using
Catch ex As Exception
End Try