.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help Deleting Layer

2 REPLIES 2
Reply
Message 1 of 3
HJohn
221 Views, 2 Replies

Help Deleting Layer

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.
2 REPLIES 2
Message 2 of 3
Anonymous
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.
Message 3 of 3
HJohn
in reply to: HJohn

Thank you tp, great help

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost