Just curious about this. Why would the following code not require a transaction?
Essentially filtering and erasing objects.
Dim psr As PromptSelectionResult = ed.SelectAll(filter) If psr.Status = PromptStatus.OK Then Dim idarray As ObjectId() = psr.Value.GetObjectIds() For Each ObjID In idarray Dim Ent As Entity = ObjID.GetObject(OpenMode.ForWrite) If TypeOf Ent Is Polyline Then Ent.Erase() End If Next End If
@SRSDS wrote:Just curious about this. Why would the following code not require a transaction?
Essentially filtering and erasing objects.
Dim psr As PromptSelectionResult = ed.SelectAll(filter) If psr.Status = PromptStatus.OK Then Dim idarray As ObjectId() = psr.Value.GetObjectIds() For Each ObjID In idarray Dim Ent As Entity = ObjID.GetObject(OpenMode.ForWrite) If TypeOf Ent Is Polyline Then Ent.Erase() End If Next End If
The code does require a transaction. If it doesn't fail, it is because there is an active transaction in the document you're running it in.
The ObjectId.GetObject() method simply calls the GetObject() method of the active Transaction returned by the TransactionManager's TopTransaction property, and if there is no active transaction, it will fail.