Looping a complex algorithm

Ehi @hepner !
So nice to see someone working in the same direction!
When I was doing some research on this, it was really hard to find info on some specific topic and one was exactly the one you’re adressing now.
You’ll have to deal with the misterious transactions nodes

Basically Dynamo is a coding environment that’s indipendent from Revit, although it can be integrated into it.
Some nodes perform operations inside Dynamo, like operations on variables, creating geometry and so on.
Other nodes are designed to make Revit do things. This is done by calling some functions from the Revit API. But the way this is done is a bit tricky: what I have understood is that Dynamo creates a list of operations that Revit has to perform (ex. create a slab, create a wall, modify the height of the created wall ecc…) and then it pushes these operations into Revit whenever the current transaction (between Dynamo and Revit) ends. When the transaction terminates, also Revit refreshes and all the required operations take place; so you will see appear, all at one time, all the requested elements.
So, what’s this transaction? Dynamo creates a global transaction with Revit that ends whenever the Dynamo script ends. So, Revit will perform the requested operations all at one time when the Dynamo script will end.

And here come some problems! There are cases in which you want to have more than one global transaction!

Take my example above:
1. create a slab, 2. create a wall, 3. modify the height of the created wall
In this script step 3 won’t work and you’ll get an error! As you have just one transaction, Revit will receive the three operations at the same time, will try to execute them and only AFTER this it will refresh and actually generate the elements.
So, it’s like Revit will try to modify a wall that’s still not there…

How to fix this?
You have to manually end the current transaction and begin another one BEFORE the wall gets modified:

  1. create a slab, 2. create a wall, 3. transaction end, 4. transacton start, 5. modify the height of the created wall.

Passthrougs are no use here. They just help you to set the order of exectution, but your problem arises when Dynamo has to pass informations to Revit and this is done by transactions.

In your case Revit has to refresh each time you request a modication to an element and then export, otherwise it will correctly loop, but without having actualy modified the elements!
So you have to end and restart the transaction before exporting inside the custom node.

Something like this:

Let me know if it works!

4 Likes