This will erase all the blocks in the blocks definitions
of the current drawing.
{code}
Public Sub eraseBlockDefinitions()
' get Local Drawing
Using db As Database = HostApplicationServices.WorkingDatabase()
Using tr As Transaction = db.TransactionManager.StartTransaction()
Dim dwg As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Using lock As DocumentLock = dwg.LockDocument
Using BT As BlockTable = dwg.Database.BlockTableId.GetObject(OpenMode.ForRead)
Using BTE As SymbolTableEnumerator = BT.GetEnumerator
' step through block definitions
While BTE.MoveNext = True
Try
Using myBTR As BlockTableRecord = BTE.Current.GetObject(OpenMode.ForWrite)
If Not myBTR.IsErased Then
' remove if you want to delete references also
If Not (myBTR.IsFromExternalReference Or myBTR.IsFromOverlayReference) Then
If Not myBTR.IsLayout Then
myBTR.Erase()
End If
End If
End If
End Using
Catch ex As Exception
' msgbox("Something is wrong" & ex.tostring)
End Try
End While
' Commit changes
tr.Commit()
End Using
End Using
End Using
End Using
End Using
' Update Drawing View
regen()
End Sub
Sub regen()
Dim MyDWG As Autodesk.AutoCAD.ApplicationServices.Document
MyDWG = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim MyEd As EditorInput.Editor
MyEd = MyDWG.Editor
MyEd.Regen()
End Sub
{code}
---------------------------
(defun botsbuildbots() (botsbuildbots))