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

Deleting a Line

1 REPLY 1
Reply
Message 1 of 2
Anonymous
228 Views, 1 Reply

Deleting a Line

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.
1 REPLY 1
Message 2 of 2
Mikko
in reply to: Anonymous

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

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