Delete an entity

Delete an entity

Anonymous
Not applicable
3,992 Views
3 Replies
Message 1 of 4

Delete an entity

Anonymous
Not applicable
I just commited a deletion an entity belonged to selection set.
Any help, I would appreciate it.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Interop.Common
Public Class GILSclass
_
Public Sub NFU()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase()
Try
Using trans As Transaction = db.TransactionManager.StartTransaction()
Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}
Dim sftr1 As New SelectionFilter(vls1)
Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)
Dim i As Integer
Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet = rs1.Value
Dim idary1 As ObjectId() = SS1.GetObjectIds()
For i = 0 To idary1.Length - 1
Dim ent1 As DBText = trans.GetObject(idary1(i), OpenMode.ForRead, False)
ent1.Erase()
Next
End Using
Catch ex As Exception
Finally
End Try
End Sub
End Class
0 Likes
3,993 Views
3 Replies
Replies (3)
Message 2 of 4

Anonymous
Not applicable
try to open the database "forwrite".
Ciao
GPaolo



ha scritto nel messaggio news:5400144@discussion.autodesk.com...
I just commited a deletion an entity belonged to selection set.
Any help, I would appreciate it.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Interop.Common
Public Class GILSclass
_
Public Sub NFU()
Dim ed As Editor =
Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase()
Try
Using trans As Transaction =
db.TransactionManager.StartTransaction()
Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}
Dim sftr1 As New SelectionFilter(vls1)
Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)
Dim i As Integer
Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet =
rs1.Value
Dim idary1 As ObjectId() = SS1.GetObjectIds()
For i = 0 To idary1.Length - 1
Dim ent1 As DBText = trans.GetObject(idary1(i),
OpenMode.ForRead, False)
ent1.Erase()
Next
End Using
Catch ex As Exception
Finally
End Try
End Sub
End Class
0 Likes
Message 3 of 4

Anonymous
Not applicable
Imports AcDb = Autodesk.AutoCAD.DatabaseServices

Friend Sub EraseEntities(ByVal entitiy As AcDb.Entity)
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Dim ent As AcDb.Entity = tr.GetObject(entitiy.ObjectId,
AcDb.OpenMode.ForWrite, False, True)
ent.Erase()
ent.Dispose()
tr.Commit()
End Using
End Using
End Sub

Friend Sub EraseEntities(ByVal entities() As AcDb.Entity)
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
For Each e As AcDb.Entity In entities
Dim ent As AcDb.Entity = tr.GetObject(e.ObjectId,
AcDb.OpenMode.ForWrite, False, True)
ent.Erase()
ent.Dispose()
Next
tr.Commit()
End Using
End Using
End Sub

Friend Sub EraseEntities(ByVal entitiy As AcDb.ObjectId)
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
Dim ent As AcDb.Entity = tr.GetObject(entitiy,
AcDb.OpenMode.ForWrite, False, True)
ent.Erase()
ent.Dispose()
tr.Commit()
End Using
End Using
End Sub

Friend Sub EraseEntities(ByVal entities() As AcDb.ObjectId)
Using db As AcDb.Database =
AcDb.HostApplicationServices.WorkingDatabase()
Using tr As AcDb.Transaction =
db.TransactionManager.StartTransaction
For Each id As AcDb.ObjectId In entities
Dim ent As AcDb.Entity = tr.GetObject(id,
AcDb.OpenMode.ForWrite, False, True)
ent.Erase()
ent.Dispose()
Next
tr.Commit()
End Using
End Using
End Sub

tp










escreveu na mensagem news:5400144@discussion.autodesk.com...
I just commited a deletion an entity belonged to selection set.
Any help, I would appreciate it.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Interop.Common
Public Class GILSclass
_
Public Sub NFU()
Dim ed As Editor =
Application.DocumentManager.MdiActiveDocument.Editor
Dim db As Database = HostApplicationServices.WorkingDatabase()
Try
Using trans As Transaction =
db.TransactionManager.StartTransaction()
Dim vls1() As TypedValue = {New TypedValue(8, "LEVEL")}
Dim sftr1 As New SelectionFilter(vls1)
Dim rs1 As PromptSelectionResult = ed.SelectAll(sftr1)
Dim i As Integer
Dim SS1 As Autodesk.AutoCAD.EditorInput.SelectionSet =
rs1.Value
Dim idary1 As ObjectId() = SS1.GetObjectIds()
For i = 0 To idary1.Length - 1
Dim ent1 As DBText = trans.GetObject(idary1(i),
OpenMode.ForRead, False)
ent1.Erase()
Next
End Using
Catch ex As Exception
Finally
End Try
End Sub
End Class



I'm protected by SpamBrave
http://www.spambrave.com/
0 Likes
Message 4 of 4

Anonymous
Not applicable
Thank you for your code, It helped.
0 Likes