.NET

Reply
Distinguished Contributor
HJohn
Posts: 340
Registered: ‎12-12-2003
Message 1 of 3 (93 Views)

Help Deleting Layer

93 Views, 2 Replies
09-28-2006 07:35 AM
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.
*tp
Message 2 of 3 (93 Views)

Re: Help Deleting Layer

09-28-2006 12:18 PM in reply to: HJohn
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.
Distinguished Contributor
HJohn
Posts: 340
Registered: ‎12-12-2003
Message 3 of 3 (93 Views)

Re: Help Deleting Layer

10-02-2006 06:08 AM in reply to: HJohn
Thank you tp, great help
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.