Hi
I have a requirement which says, I have to open a dwg file, where I have to select some few polylines and then the selected polylines should be deleted.
I am able to select objects in the dwg file, but not able to delete it.
I am using AutoCAD Map 3D 2012 and VB.NET.
Here I am pasting part of the code that I am having as of now.
Dim acDocMgr As DocumentCollection = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager
Dim acDoc As Document = acDocMgr.MdiActiveDocument
'Get the selected objects in the drawing area
Dim acSSPrompt As PromptSelectionResult = acDoc.Editor.GetSelection()
MsgBox(acSSPrompt.Status)
'If the prompt Status is OK, the objects are selected
If acSSPrompt.Status = PromptStatus.OK Then
MsgBox("OK")
'Selection Set for the selected objects
Dim acSSet As SelectionSet = acSSPrompt.Value
For Each acSSObj As SelectedObject In acSSet
Dim myMap As New Autodesk.AutoCAD.DatabaseServices.IdMapping
Dim myObjs As New Autodesk.AutoCAD.DatabaseServices.ObjectIdCollection
If Not IsDBNull(acSSObj) Then
'Open the selected object for READ
Using trans As Transaction = acDoc.Database.TransactionManager.StartTransaction()
Using lock As DocumentLock = acDoc.LockDocument
Dim acEnt As Entity = DirectCast(trans.GetObject(acSSObj.ObjectId, OpenMode.ForWrite), Entity)
acEnt.UpgradeOpen()
acEnt.Erase()
End Using
End Using
trans.Commit()
End If
Next