This is copied from
http://www.cadtutor.net/forum/showthread.php?55948-.NET-Getting-a-block-nameI did not know how to insert pictures so posted here
When you change the properties of a dynamic block it creates an anonymous block.
This is a simple example to delete the block references and delete the block references of the anonymous blocks created by the dynamic block.
Is hard-coded for a block named "C"
<CommandMethod("DeleteAllBlockReference")> _
Public Sub DeleteAllBlockReference()
Dim doc As Document = Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Using trx As Transaction = db.TransactionManager.StartTransaction()
Dim bt As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)
Dim btr As BlockTableRecord = bt("C").GetObject(OpenMode.ForRead)
For Each objId As ObjectId In btr.GetBlockReferenceIds(True, True)
Dim ent As Entity = objId.GetObject(OpenMode.ForWrite)
ent.Erase()
Next
Dim anonBlkIds As ObjectIdCollection = btr.GetAnonymousBlockIds
For Each btrObjId As ObjectId In anonBlkIds
Dim anonBtr As BlockTableRecord = btrObjId.GetObject(OpenMode.ForRead)
For Each objId As ObjectId In anonBtr.GetBlockReferenceIds(True, True)
Dim ent As Entity = objId.GetObject(OpenMode.ForWrite)
ent.Erase()
Next
Next
trx.Commit()
End Using
End Sub
The first pic shows 10 or so dynamic blocks inserted.
The second pic shows after 4 of the dynamic properties have been changed