Transactions in Python

I’m struggling to understand how transactions work in python in RhinoInside.Revit.

Using the TransactionManager gives me and “outside of API context” error.

I tried using trans.Start() and trans.Commit(), but that seemed a little unstable and caused weird things to happen in my project browser.

And I have used EnqueueAction with success, but I don’t understand how it works. And inside this Action I don’t get any errors if something isn’t working, so if it doesn’t do what i want it to do, i usually have to resort to adding one line at a time and constantly rerunning until I find my error.

But all of this is to try to understand how I might use EditFamily in my script to add geometry to a family and reload it into the project. In the past, I used TransactionManager with a new transaction for the familyManager, but TransactionManager doesn’t seem to be the way to go with RiR.

Any help with understanding transactions in RiR context and with how to get them to work with the EditFamily and FamilyManager would be super helpful. Thanks!