.NET

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

Help Deleting Layer

92 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 (92 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 (92 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
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!