How do you delete/purge a block table record? The code I have below deletes a specific block and attempts to purge the block def. The ent gets erased ok, but the block table gets messed up.
[code]Public Sub RemoveStamp()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = New Database(False, False)
Dim t As Transaction = doc.TransactionManager.StartTransaction
Try
' delete block insertion
Dim bref As BlockReference = CType(t.GetObject(brefID, OpenMode.ForWrite), BlockReference)
' delete block definition
Dim bt As BlockTable = CType(t.GetObject(doc.Database.BlockTableId, OpenMode.ForWrite), BlockTable)
Dim btr As BlockTableRecord = CType(t.GetObject(btrID, OpenMode.ForWrite), BlockTableRecord)
Try
bref.Erase()
btr.Erase()
Finally
CType(bref, IDisposable).Dispose()
CType(btr, IDisposable).Dispose()
End Try
t.Commit()
t.Dispose()
Finally
CType(t, IDisposable).Dispose()
End Try
End Sub[/code]
Ed
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to
post your code.