[transaction] difference

[transaction] difference

Joris.vd.Meulen
Collaborator Collaborator
524 Views
3 Replies
Message 1 of 4

[transaction] difference

Joris.vd.Meulen
Collaborator
Collaborator

What is the difference between:

 

//used here for example (https://www.revitapidocs.com/2017/31b73d46-7d67-5dbb-4dad-80aa597c9afc.htm)
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.ReadOnly)]
//used in my coding
[Transaction(TransactionMode.Manual)]

 

love python coding
0 Likes
525 Views
3 Replies
Replies (3)
Message 2 of 4

jeremytammik
Autodesk
Autodesk

Try it out!

 

Always try out everything!

 

Never trust anybody except your own code!

 

Still, if you insist:

 

If you set your transaction mode to read-only, Revit will throw an exception if you try to open a transaction.

 

That guarantees that your add-in will under no circumstances be able to modify any documents.

 

Cheers,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 4

Joris.vd.Meulen
Collaborator
Collaborator

Hi @jeremytammik ,

 

Fiddling with C# that is what I'm doing all the time. Smiley Very Happy

 

So if an addin has no intention of altering the model itself, the TransactionMode should always be ReadOnly. 

Because

1. safer

2. clear coding / understandable

3. faster (???) (For example: I can imagine that selection addin in ReadOnly could be faster than Manual selecting 100k elements?)

 

 

love python coding
0 Likes
Message 4 of 4

jeremytammik
Autodesk
Autodesk

Dear Joris,

 

Thank you for your update.

 

> So, if an add-in has no intention of altering the model itself, the TransactionMode should always be ReadOnly.

 

Yes, absolutely!

 

> safer

 

Yes.

 

> clear coding / understandable

 

Yes.

 

> faster (???) (For example: I can imagine that selection addin in ReadOnly could be faster than Manual selecting 100k elements?)

 

Unknown. Please try it out and let us know.

 

Thank you!

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder