Script only runs when changing list level back and forth

I am creating a script in Dynamo that will be opened up in a template file, and when I run the script, it will grab chosen parameters from that opened family, and transfer its value to other open families, changing the parameter value in those families (that have the same parameter name).

For some reason every single time I open up this script and start to run it, it gives an error message, and I have to disconnect and run it, and reconnect and run it, and then it works. Or I can change the list level back and forth, and it will work. But never for the first time.

Also, it never seems to be willing to do this process on both of the other families, only one at a time. One of them will always give an error code, and I have to change the list level back and forth for each one before each time I run it to get this final result that I want. But if I opened up this script again, it would not work immediately.
What is happening here?

Here is a video as well: Dynamo Problem - YouTube

What does the error say?

My guess is a transaction is required between selecting your data and running the SetParameterValueByName nodes. By default, Dynamo will wrap everything in the graph inside one Revit transaction. Some scenarios require a transaction to create an object and another transaction to utilize that object. (Example: One transaction to create a sheet in the project and another transaction to change its name.)

It’s also possible the SetParameterValueByName nodes can only write to one document at a time. That probably isn’t the case unless you’re trying to write to the same family document with both.

1 Like

Thank you! This is the error code that I get:

Warning: FamilyDocument.SetParameterValueByName operation failed.
A sub-transaction can only be active inside an open Transaction.

So how do I exactly fix that? I am not even sure what this transaction thing mean.

You can think of a transaction as the all-encompassing “action” that Revit sees in the command log. Dynamo runs as a single transaction when it’s pushed to Revit, so Revit only tracks that there was one Dynamo “action” even if you did multiple things within the graph.
image

What this means is that nothing occurs in Revit until everything occurs in Revit, unless you add additional transactions. Try adding a Transaction node (start or stop is fine in this case) before writing to the parameter. You may also need a node that opens the FamilyDocument before writing to it as well.

If that still doesn’t work I’d suggest doing some more research on the forums for other topics dealing with writing to FamilyDocuments as there are some custom packages that are setup for exactly this and some specific best practices and workflows that go along with them.

1 Like

Thanks. I will try that.

It worked! It’s very helpful, thanks!

1 Like

So the first issue was definitely solved, but when I try with multiple open documents, it can do only one at a time. The other ones will give the same message:


Is there a way to make this happen at once? I tried by adding some start and end nodes here, but then it did not work at all, but I might have put them at the wrong place.

I don’t think you can run them in parallel since they each need their own transaction. You would have to string them together to run one document after another, each with their own transaction. You can use a Wait or Passthrough node to force the order if you have to.

1 Like

What do you think of this? Should be applied to all input? It seems that I got this message again.

Same issue :confused:

One wait node per document should be enough, but you still need a transaction node in between as well.

1 Like

Thanks. This is how I actually modified it before I saw your latest reply, but this didn’t work. Did I put the transaction node to the wrong place? The error code is still the same:

You may have to do a full Start and Stop for each transaction now, so two nodes per document.

1 Like