help you in vb.net?
Imports AcDb = Autodesk.AutoCAD.DatabaseServices
Imports AcRx = Autodesk.AutoCAD.Runtime
Module Module1
_
Public Sub PurgeLayers()
Using db As AcDb.Database = AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction = db.TransactionManager.StartTransaction
Try
Dim tbl As AcDb.LayerTable = tr.GetObject(db.LayerTableId,
AcDb.OpenMode.ForRead)
Dim ids As New AcDb.ObjectIdCollection
For Each id As AcDb.ObjectId In tbl
Dim rec As AcDb.LayerTableRecord = tr.GetObject(id, AcDb.OpenMode.ForRead)
ids.Add(rec.ObjectId)
Next
db.Purge(ids)
If ids.Count > 0 Then
For Each id As AcDb.ObjectId In ids
Dim ltr As AcDb.LayerTableRecord = tr.GetObject(id, AcDb.OpenMode.ForWrite)
ltr.Erase()
Next
End If
tr.Commit()
Catch ex As Exception
tr.Abort()
End Try
End Using
End Using
End Sub
End Module
escreveu na mensagem news:5343916@discussion.autodesk.com...
How could I determine that a layer is no used in the drawing and can be
erased? I get error when trying to delete a layer that is contains entities
on it.