How to pass inputs to a Dynamo script from a Revit add-in?

I’ve referred to this post - Run a.dyn from a Revit add-in? - #8 by klawson
It specifies how to run a script from Revit add-in but not how to pass inputs to it.

I checked the Github of DynamoRevit, specifically this - DynamoRevit/DynamoRevit.cs at a1da1b8d01300ff655c17251efb9090b77990e1c · DynamoDS/DynamoRevit · GitHub

There is a key called ModelNodesInfo in the JournalData dictionary. It expects a list of dictionaries.
Each entry has Id, Name and Value of the node to be filled in with input.

I tried this, should work theoretically, but is not working. I’m not sure what the Id property should be, since nodes on Dynamo don’t seem to have an ID.

The code says modelGuid, but I’m not sure how to get it.
The documentation on Dynamo API is virtually inexistent.

Can someone point me in the right direction?

I’d a few more screenshots, but new users can only have 1 embedded media per post

Edit the values in the .dyn’s json structure prior to sending.

1 Like

Do you mean like this?

I only have the link to the .dyn file and nothing else

Open the .dyn as if it was a .json file. Then find the inputs (in the input section of the json). Then find the matching nodes (in the nodes section) and adjust values accordingly.

No need for dynamo API or other tooling beyond a json read/write too, and even then you can just read the file as a giant string and use find/replace if that’s too much.

2 Likes

Oh wow, the bare bones approach. Thanks!

Conversely, how to get the Dynamo script’s output to the add-in?

Why would you want to do this instead of running via Player directly? Seems like you’ve gone from a niche use case to doing way more work then you ought.

I’d likely write to a temp file as the VM where Dynamo is will be unassociated to your add-in so the memory won’t transfer; sending to clipboard to writing to a temp file are the two best ways to do this.

Good afternoon.
I’m a newbie
You can attach a sample code.

What for?

To pass input data to the bin script, which is executed inside the revit add-in.

The easy way is to write the data to a temp file on the disc, and have the add-in read the data from there. As far as sample code, it’s tough to produce as we don’t know what code you’re producing, with all of this being so theoretical that I’m not sure where to start.