Message 1 of 4
vb.net: erase all queried objects
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi All, can you help me figure out why I cant' get the enties for WRITE mode with this code. It crashes if I try to open the entity for write?
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim psr As PromptSelectionResult = ed.SelectAll()
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
For Each id As ObjectId In psr.Value.GetObjectIds()
Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForWrite), Entity)
ent.UpgradeOpen()
ent.Erase()
ent.Dispose()
Next
tr.Commit()
End Using
Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim db As Database = doc.Database
Dim ed As Editor = doc.Editor
Dim psr As PromptSelectionResult = ed.SelectAll()
Dim tr As Transaction = db.TransactionManager.StartTransaction()
Using tr
For Each id As ObjectId In psr.Value.GetObjectIds()
Dim ent As Entity = DirectCast(tr.GetObject(id, OpenMode.ForWrite), Entity)
ent.UpgradeOpen()
ent.Erase()
ent.Dispose()
Next
tr.Commit()
End Using