<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Delete an entity in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822553#M79850</link>
    <description>I just commited a deletion an entity belonged to selection set.&lt;BR /&gt;
Any help, I would appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Public Class GILSclass&lt;BR /&gt;
    &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
    Public Sub NFU()&lt;BR /&gt;
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
        Try&lt;BR /&gt;
            Using trans As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}&lt;BR /&gt;
                Dim sftr1 As New SelectionFilter(vls1)&lt;BR /&gt;
                Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)&lt;BR /&gt;
                Dim i As Integer&lt;BR /&gt;
                Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet = rs1.Value&lt;BR /&gt;
                Dim idary1 As ObjectId() = SS1.GetObjectIds()&lt;BR /&gt;
                For i = 0 To idary1.Length - 1&lt;BR /&gt;
                    Dim ent1 As DBText = trans.GetObject(idary1(i), OpenMode.ForRead, False)&lt;BR /&gt;
                    ent1.Erase()&lt;BR /&gt;
                Next&lt;BR /&gt;
            End Using&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
        Finally&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;/COMMANDMETHOD&gt;</description>
    <pubDate>Fri, 17 Nov 2006 18:22:11 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2006-11-17T18:22:11Z</dc:date>
    <item>
      <title>Delete an entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822553#M79850</link>
      <description>I just commited a deletion an entity belonged to selection set.&lt;BR /&gt;
Any help, I would appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Public Class GILSclass&lt;BR /&gt;
    &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
    Public Sub NFU()&lt;BR /&gt;
        Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
        Try&lt;BR /&gt;
            Using trans As Transaction = db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}&lt;BR /&gt;
                Dim sftr1 As New SelectionFilter(vls1)&lt;BR /&gt;
                Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)&lt;BR /&gt;
                Dim i As Integer&lt;BR /&gt;
                Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet = rs1.Value&lt;BR /&gt;
                Dim idary1 As ObjectId() = SS1.GetObjectIds()&lt;BR /&gt;
                For i = 0 To idary1.Length - 1&lt;BR /&gt;
                    Dim ent1 As DBText = trans.GetObject(idary1(i), OpenMode.ForRead, False)&lt;BR /&gt;
                    ent1.Erase()&lt;BR /&gt;
                Next&lt;BR /&gt;
            End Using&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
        Finally&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;/COMMANDMETHOD&gt;</description>
      <pubDate>Fri, 17 Nov 2006 18:22:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822553#M79850</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-11-17T18:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Delete an entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822554#M79851</link>
      <description>try to open the database "forwrite".&lt;BR /&gt;
Ciao&lt;BR /&gt;
GPaolo&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;GILSEORIN&gt; ha scritto nel messaggio news:5400144@discussion.autodesk.com...&lt;BR /&gt;
I just commited a deletion an entity belonged to selection set.&lt;BR /&gt;
Any help, I would appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Public Class GILSclass&lt;BR /&gt;
    &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
    Public Sub NFU()&lt;BR /&gt;
        Dim ed As Editor =&lt;BR /&gt;
Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
        Try&lt;BR /&gt;
            Using trans As Transaction =&lt;BR /&gt;
db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}&lt;BR /&gt;
                Dim sftr1 As New SelectionFilter(vls1)&lt;BR /&gt;
                Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)&lt;BR /&gt;
                Dim i As Integer&lt;BR /&gt;
                Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet =&lt;BR /&gt;
rs1.Value&lt;BR /&gt;
                Dim idary1 As ObjectId() = SS1.GetObjectIds()&lt;BR /&gt;
                For i = 0 To idary1.Length - 1&lt;BR /&gt;
                    Dim ent1 As DBText = trans.GetObject(idary1(i),&lt;BR /&gt;
OpenMode.ForRead, False)&lt;BR /&gt;
                    ent1.Erase()&lt;BR /&gt;
                Next&lt;BR /&gt;
            End Using&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
        Finally&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;/COMMANDMETHOD&gt;&lt;/GILSEORIN&gt;</description>
      <pubDate>Sat, 18 Nov 2006 07:30:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822554#M79851</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-11-18T07:30:18Z</dc:date>
    </item>
    <item>
      <title>Re: Delete an entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822555#M79852</link>
      <description>Imports AcDb = Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
&lt;BR /&gt;
Friend Sub EraseEntities(ByVal entitiy As AcDb.Entity)&lt;BR /&gt;
   Using db As AcDb.Database =&lt;BR /&gt;
AcDb.HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
      Using tr As AcDb.Transaction = &lt;BR /&gt;
db.TransactionManager.StartTransaction&lt;BR /&gt;
         Dim ent As AcDb.Entity = tr.GetObject(entitiy.ObjectId,&lt;BR /&gt;
AcDb.OpenMode.ForWrite, False, True)&lt;BR /&gt;
         ent.Erase()&lt;BR /&gt;
         ent.Dispose()&lt;BR /&gt;
         tr.Commit()&lt;BR /&gt;
      End Using&lt;BR /&gt;
   End Using&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Friend Sub EraseEntities(ByVal entities() As AcDb.Entity)&lt;BR /&gt;
   Using db As AcDb.Database =&lt;BR /&gt;
AcDb.HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
      Using tr As AcDb.Transaction = &lt;BR /&gt;
db.TransactionManager.StartTransaction&lt;BR /&gt;
         For Each e As AcDb.Entity In entities&lt;BR /&gt;
            Dim ent As AcDb.Entity = tr.GetObject(e.ObjectId,&lt;BR /&gt;
AcDb.OpenMode.ForWrite, False, True)&lt;BR /&gt;
            ent.Erase()&lt;BR /&gt;
            ent.Dispose()&lt;BR /&gt;
         Next&lt;BR /&gt;
         tr.Commit()&lt;BR /&gt;
      End Using&lt;BR /&gt;
   End Using&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Friend Sub EraseEntities(ByVal entitiy As AcDb.ObjectId)&lt;BR /&gt;
   Using db As AcDb.Database =&lt;BR /&gt;
AcDb.HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
      Using tr As AcDb.Transaction = &lt;BR /&gt;
db.TransactionManager.StartTransaction&lt;BR /&gt;
         Dim ent As AcDb.Entity = tr.GetObject(entitiy,&lt;BR /&gt;
AcDb.OpenMode.ForWrite, False, True)&lt;BR /&gt;
         ent.Erase()&lt;BR /&gt;
         ent.Dispose()&lt;BR /&gt;
         tr.Commit()&lt;BR /&gt;
      End Using&lt;BR /&gt;
   End Using&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
Friend Sub EraseEntities(ByVal entities() As AcDb.ObjectId)&lt;BR /&gt;
   Using db As AcDb.Database =&lt;BR /&gt;
AcDb.HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
      Using tr As AcDb.Transaction = &lt;BR /&gt;
db.TransactionManager.StartTransaction&lt;BR /&gt;
         For Each id As AcDb.ObjectId In entities&lt;BR /&gt;
            Dim ent As AcDb.Entity = tr.GetObject(id,&lt;BR /&gt;
AcDb.OpenMode.ForWrite, False, True)&lt;BR /&gt;
            ent.Erase()&lt;BR /&gt;
            ent.Dispose()&lt;BR /&gt;
         Next&lt;BR /&gt;
         tr.Commit()&lt;BR /&gt;
      End Using&lt;BR /&gt;
   End Using&lt;BR /&gt;
End Sub&lt;BR /&gt;
&lt;BR /&gt;
tp&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;GILSEORIN&gt; escreveu na mensagem news:5400144@discussion.autodesk.com...&lt;BR /&gt;
I just commited a deletion an entity belonged to selection set.&lt;BR /&gt;
Any help, I would appreciate it.&lt;BR /&gt;
&lt;BR /&gt;
Imports Autodesk.AutoCAD.Runtime&lt;BR /&gt;
Imports Autodesk.AutoCAD.DatabaseServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.EditorInput&lt;BR /&gt;
Imports Autodesk.AutoCAD.ApplicationServices&lt;BR /&gt;
Imports Autodesk.AutoCAD.Interop.Common&lt;BR /&gt;
Public Class GILSclass&lt;BR /&gt;
    &lt;COMMANDMETHOD&gt; _&lt;BR /&gt;
    Public Sub NFU()&lt;BR /&gt;
        Dim ed As Editor =&lt;BR /&gt;
Application.DocumentManager.MdiActiveDocument.Editor&lt;BR /&gt;
        Dim db As Database = HostApplicationServices.WorkingDatabase()&lt;BR /&gt;
        Try&lt;BR /&gt;
            Using trans As Transaction =&lt;BR /&gt;
db.TransactionManager.StartTransaction()&lt;BR /&gt;
                Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}&lt;BR /&gt;
                Dim sftr1 As New SelectionFilter(vls1)&lt;BR /&gt;
                Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)&lt;BR /&gt;
                Dim i As Integer&lt;BR /&gt;
                Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet =&lt;BR /&gt;
rs1.Value&lt;BR /&gt;
                Dim idary1 As ObjectId() = SS1.GetObjectIds()&lt;BR /&gt;
                For i = 0 To idary1.Length - 1&lt;BR /&gt;
                    Dim ent1 As DBText = trans.GetObject(idary1(i),&lt;BR /&gt;
OpenMode.ForRead, False)&lt;BR /&gt;
                    ent1.Erase()&lt;BR /&gt;
                Next&lt;BR /&gt;
            End Using&lt;BR /&gt;
        Catch ex As Exception&lt;BR /&gt;
        Finally&lt;BR /&gt;
        End Try&lt;BR /&gt;
    End Sub&lt;BR /&gt;
End Class&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I'm protected by SpamBrave&lt;BR /&gt;
http://www.spambrave.com/&lt;/COMMANDMETHOD&gt;&lt;/GILSEORIN&gt;</description>
      <pubDate>Sat, 18 Nov 2006 14:43:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822555#M79852</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-11-18T14:43:58Z</dc:date>
    </item>
    <item>
      <title>Re: Delete an entity</title>
      <link>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822556#M79853</link>
      <description>Thank you for your code, It helped.</description>
      <pubDate>Sat, 18 Nov 2006 19:32:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/delete-an-entity/m-p/1822556#M79853</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2006-11-18T19:32:55Z</dc:date>
    </item>
  </channel>
</rss>

