Give that a try just change the block
name to your suit
Public Sub PurgeBlockMethod()
Using db As Database = HostApplicationServices.WorkingDatabase
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Try
Dim tv() As TypedValue = {New TypedValue(DxfCode.Start, "INSERT"), New TypedValue(DxfCode.BlockName, "MyBlock")}
Dim sf As SelectionFilter = New SelectionFilter(tv)
Dim psr As PromptSelectionResult = ed.SelectAll(sf)
If psr.Status = PromptStatus.OK Then
Dim ss As SelectionSet = psr.Value
Dim idarr As ObjectId() = ss.GetObjectIds()
Dim id As ObjectId
For Each id In idarr
Dim e As Entity = CType(tr.GetObject(id, OpenMode.ForWrite, True), Entity)
e.Erase()
Next id
End If
Dim bt As BlockTable = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
If Not bt.Has("MyBlock") Then
MessageBox.Show("block MyBlock does not exist")
Return
End If
Dim btr As BlockTableRecord = tr.GetObject(bt("MyBlock"), OpenMode.ForWrite, True, True)
Dim idcoll As ObjectIdCollection = New ObjectIdCollection()
idcoll.Add(btr.ObjectId)
db.Purge(idcoll)
btr.Erase(True)
tr.Commit()
Catch ex As Autodesk.AutoCAD.Runtime.Exception
MessageBox.Show(ex.StackTrace)
End Try
End Using
End Using
End Sub
~'J'~