.NET

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

Help Deleting Layer

88 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 (88 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 (88 Views)

Re: Help Deleting Layer

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community