Message 1 of 10

Not applicable
03-13-2015
11:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone,
I am using the following code to erase all unused (not inserted) blocks from a drawing:
Sub PurgeAll(ByVal myDB As Database)
' This procedure purge all the blocks that are not inserted in the drawing
Using myTrans As Transaction = myDB.TransactionManager.StartTransaction
Dim myBT As BlockTable = myDB.BlockTableId.GetObject(OpenMode.ForRead)
For Each id As ObjectId In myBT
Dim myBTR As BlockTableRecord = CType(myTrans.GetObject(id, OpenMode.ForWrite), BlockTableRecord)
If myBTR.GetBlockReferenceIds(False, False).Count = 0 And Not myBTR.IsLayout Then
myBTR.Erase()
End If
Next
myTrans.Commit()
End Using
End Sub
Nevertheless, in some drawings the GetBlockReferenceIds.count function returns 1 for some blocks even though there are no instances inserted. I confirmed there are no blocks inserted erasing the blocks manually with the Purge command.
Why is this happening?
Thanks!
Solved! Go to Solution.