In the last post we saw how the Data.Gate node can be used to send geometry to Revit 2021 when the “Create Revit Elements” button gets pressed from the Explore Outcomes UI for a Generative Design study. Phew.
In this post we’re going to dig into how this node can also be used to have other “side effects” such as storing the various input parameters to a text file. For the purpose of this workflow I’ve chosen to hack the standard Three Box Massing.dyn graph (which ships with Revit 2021 as a sample for the Generative Design feature).
The general approach I took was to take the graph’s input parameters and combine them into a list that gets encoded as a string. This is the input for the Data.Gate node (actually the second Data.Gate node, as I’ve left the one that controls the Revit geometry creation). When the gate is opened, this string will get appended to an arbitrary text file (which I happen to store at “c:\temp\designs.txt”).
Here’s the modified graph (which you can also download from here):
Here’s a close-up of the area with the most significant changes:
Let’s now take a look at the results of this workflow. I’ve compiled the below animation from screenshots of the various designs being selected in the Explore Outcomes UI alongside the output in the designs.txt text file. Bear in mind I haven’t shown the steps where the “Create Revit Elements” button is pressed, or the text file is (manually) reloaded into Notepad once the Revit elements have been created and designs.txt updated – something that I did manually after selecting each design
Of course more work will be needed to make sure the file is cleared at appropriate times (and perhaps having a separate file for each model).
One addition question relates to getting this working outside of Revit – such as when running Dynamo Sandbox (and the Generative Design feature in standalone mode). In this scenario there is no “Create Revit Elements” button: it’s replaced with a “Open in Dynamo” button, which doesn’t cause the Data.Gate nodes to be opened.
If you want your side effect to be executed when “Open in Dynamo” is pressed, the simplest answer is probably to publish a version of the graph that does not have a Data.Gate controlling this logic: in this scenario it would always write the input parameters to a file. Having the graph set to run automatically would also make the process a little more streamlined. The downside to this is – of course – that this side effect will happen for each execution of the graph, even when it’s being managed by the Generative Design feature. This isn’t necessarily a problem, but your workflow would need to manage the step of removing (or emptying) the file before the user selection process starts.
So what can we do with this set of selected designs? It would be a great way to drive a tool such as Capturefinery that collects more interesting graphical detail about the design, for instance. (Right now Capturefinery works with the output of the GD feature – which is stored in JSON and CSV files – but it wouldn’t be so hard to either create a file with a similar structure directly from Dynamo or to adapt the Capturefinery code to load this simplified version of the parameter data.)