Transaction fails first time, works second


I’m writing some test code which modifies the crop shape of an elevation wall to a new size - this will be part of a larger routine.

The issue I have is that when I run the code, it fails with the error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed. _
Traceback (most recent call last):
_ File “”, line 71, in

Exception: Starting a new transaction is not permitted. It could be because another transaction already started and has not been completed yet, or the document is in a state in which it cannot start a new transaction (e.g. during failure handling or a read-only mode, which could be either permanent or temporary).

But if I do nothing other than click the Boolean node and change it from False to True (or the other way), the script runs flawlessly and modifies the crop box as required.

The boolean does nothing in the script, I simply have it there so I can run the script a second time.

I’ve attached the Revit file and Dynamo file:

Set CropRegion of Elevation 01.dyn (9.8 KB)
Example View crop change.rvt (1.3 MB)

The script should modify the view crop from this:

To match the red line.

I don’t understand why it fails the first time and works the second when no changes have been made.

Perhaps the first time closes the error to allow the second time to work, but I can’t use this in my final script as I need it to work all the time.

Am I missing something?


OK, I’ve found out that I can run the routine without a transaction and it works every time.

I guess it works because its being covered by Dynamo’s transaction…

Not too sure why though, when I do use a transaction it fails the first time and works the second…