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

When do I need to open a Transaction?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
SRSDS
453 Views, 2 Replies

When do I need to open a Transaction?

Hi,

 

I often see examples of accessing objects without opening a transaction.

 

This has no reference to a transaction

Dim Ent As Entity = ObjID.GetObject(OpenMode.ForRead)

but when I try to use it in a reactor it jumps to the ObjectModified event and then not back to the continuing code. 

 

I have this in my CommandEnded event

           ElseIf e.GlobalCommandName = "EATTEDIT" Then
                'Check if DrawingNo changed
                Dim Ent As Entity = ObjID.GetObject(OpenMode.ForRead)
                Dim myXdata As Array = Ent.XData.AsArray
                If myXdata.GetValue(0).value = "TitleBlock" Then

 And don't understand why I need to open a transaction to see if it's a Titleblock

 

What's the difference between

Dim Ent As Entity = ObjID.GetObject(OpenMode.ForRead)

and

Dim Ent As Entity = trans.GetObject(ObjID, OpenMode.ForRead)

Hope someone can help.

2 REPLIES 2
Message 2 of 3
chiefbraincloud
in reply to: SRSDS


@SRSDS wrote:

What's the difference between

Dim Ent As Entity = ObjID.GetObject(OpenMode.ForRead)

and

Dim Ent As Entity = trans.GetObject(ObjID, OpenMode.ForRead)


Short answer, there isn't one.  You must have an active transaction to call GetObject.  Even when you call Objid.GetObject, the Top Level Transaction still handles the object, so if there is no active transaction it will fail.

Dave O.                                                                  Sig-Logos32.png
Message 3 of 3
SRSDS
in reply to: chiefbraincloud

Thanks Chief,

 It looks like I'm doing it right then.

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