.NET

Reply
New Member
Jeff_Hoffelner
Posts: 1
Registered: ‎12-13-2005
Message 1 of 2 (71 Views)

Deleting a Line

71 Views, 1 Replies
12-13-2005 08:36 AM
I have been trying to delete a AcadLine object from a AutoCad 2006 drawing. I have been using the "Delete" method and then regenerating the document. This doesn't raise a error but it doesn't delete the line either. Any help you can give would be appreciated.

Thanks.
Distinguished Contributor
Mikko
Posts: 212
Registered: ‎10-03-2003
Message 2 of 2 (71 Views)

Re: Deleting a Line

12-13-2005 09:02 AM in reply to: Jeff_Hoffelner
Public Sub remove_Line()
Dim ed As Editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase
Dim tm As Transaction = db.TransactionManager.StartTransaction()
Try
Dim res As PromptSelectionResult = ed.GetSelection
If res.Status <> PromptStatus.OK Then
Exit Sub
End If
Dim SS As Autodesk.AutoCAD.EditorInput.SelectionSet = res.Value
Dim tempIdArray() As ObjectId
tempIdArray = SS.GetObjectIds()
Dim tempId As ObjectId
For Each tempId In tempIdArray
Dim Ent As Entity = CType(tm.GetObject(tempId, OpenMode.ForWrite), Entity)
If Ent.GetType.Name.ToString() = "Line" Then
Ent.Erase()
End If
Next
tm.Commit()
Catch
Finally
tm.Dispose()
End Try
End Sub
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.