Good TransactionManager practice


I recently started working with some bigger scripts that will make adjustments to sheets in bulk. As we have 200+ sheets that work identical, automatic sheet makers would be amazing.

Now I have a few questions regarding the TransactionManager, of which I couldn’t really find in-depth info:

  1. In larger scripts; is it good practice to start and end it at each definition? Or is starting the Transaction once per script enough?
  2. Do I have to regenerate the doc? Let’s say I wanted to place a sheet, place viewports, and then read some info about their location, is the doc then updated automatically?
  3. Is it possible that data differs when a transaction is not started?
  4. When specifically, is the TransactionManager really needed (or is it always good practice to start it in any script)?
  5. Could you explain why one would use Commit using the Transaction, instead of just changing data. Let’s say I wanted to change a parameter, I don’t need a Transaction for that, right?

Thanks so much for any response!


1 Like

Here are my thoughts.

  1. Dynamo handles transactions on its own and you really only should worry about it if you are either using python scripts or if you are asking your graph to “commit” or make multiple changes in a single run especially when that data is linked. IE: If you are creating views and placing them on sheets. You would need to “commit” the creation of the views BEFORE trying to place them on sheets or else Dynamo won’t be able to see them and will not work.
  2. Committing transaction is what regenerates the document and there shouldn’t be any need to try and do it manually. It is not like regen in AutoCAD if you are familiar with that. See #1 for your example. If you commit inside Python or use the Transaction.End and Transaction.Start nodes it should work fine.
  3. The only “differences” will be if the data has been committed and therefore isn’t available yet, but the actually data should be the same regardless.
  4. You only need a transaction if you are making changes to the document. If you are only reading values or exporting to excel you really don’t need one, but if you are changing Mark values or affecting views on sheets then a transaction is needed. I tell people its like shopping. You can browse all you want, but if you want to buy something you’ll need a transaction.
  5. See #4, you have it backwards. Just about ANY change to the document need a transaction, but you don’t need one to look or view information.

I’m currently working on a sheet creation script, and I found that it was necessary to end and restart the transaction after changing the Scope Box parameter. It seems that the scope box is only applied when the transaction is ended. So I would attempt to pack views on a sheet, but they wouldn’t fit because they had not been cropped. If the crop regions or scope box change on your sheets, you may need to restart the transaction to fix issues. That’s the only concern I’m currently aware of.