.NET

Reply
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 1 of 4 (606 Views)

Delete an entity

606 Views, 3 Replies
11-17-2006 10:22 AM
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
*GPaolo
Message 2 of 4 (606 Views)

Re: Delete an entity

11-17-2006 11:30 PM in reply to: gilseorin
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
*tp
Message 3 of 4 (606 Views)

Re: Delete an entity

11-18-2006 06:43 AM in reply to: gilseorin
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/
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 4 of 4 (606 Views)

Re: Delete an entity

11-18-2006 11:32 AM in reply to: gilseorin
Thank you for your code, It helped.
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

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