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

eWasErased error

2 REPLIES 2
Reply
Message 1 of 3
gilseorin
847 Views, 2 Replies

eWasErased error

Hi, everyone.
The following code is working very well.
But, After excuting layer merge, excuting the following code,
occurs eWasErased error. How should I do with my code?

Private Sub SLF_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SLF.Click
Application.DocumentManager.MdiActiveDocument.LockDocument()
Dim db As Database = Application.DocumentManager.MdiActiveDocument.Database
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor

Try
Dim entselopt As PromptEntityOptions = New PromptEntityOptions(vbCrLf + "Select Entity: ")
entselopt.AllowNone = False
entselopt.AllowObjectOnLockedLayer = True

Dim entselres As PromptEntityResult = ed.GetEntity(entselopt)
If entselres.Status <> PromptStatus.OK Then Exit Sub
Using trans As Transaction = db.TransactionManager.StartTransaction

Dim Ent As Entity = trans.GetObject(entselres.ObjectId, OpenMode.ForRead, False, True)
Dim lt As LayerTable = trans.GetObject(db.LayerTableId, OpenMode.ForRead, False, True)
lt.UpgradeOpen()
Dim ltr As LayerTableRecord = trans.GetObject(lt.Item(Ent.Layer), OpenMode.ForWrite, False, True)

For Each objId As ObjectId In lt
If Not objId.IsErased Then
Dim lyr As LayerTableRecord = CType(trans.GetObject(objId, OpenMode.ForWrite), LayerTableRecord)
If Ent.Layer.ToString = lyr.Name AndAlso objId <> db.Clayer Then
lyr.IsOff = True
End If
End If
Next
trans.Commit()
Application.DocumentManager.MdiActiveDocument.Editor.Regen()
End Using
Catch ex As Exception
ed.WriteMessage("Error: " + ex.Message)
End Try
End Sub
2 REPLIES 2
Message 2 of 3
MarkPendergraft
in reply to: gilseorin

My fault........

i usually don't open objects that have been erased, but here it remains in the table records, so....sorry. 😞

You just need to change all of your code using the trans.getobject() to open objects that have been erased.

e.g.

trans.GetObject(lt.Item(Ent.Layer), OpenMode.ForWrite, TRUE, True)
Message 3 of 3
gilseorin
in reply to: gilseorin

Thank you so much.
It's really effective.
Happy day!

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