I was inspired to write this post by a chat I had with Zachary Kron, earlier in the week. I’d been noodling on how best to support a workflow where users of the Generative Design feature in Revit 2021 can select specific solutions in a study and do something with them.
The specific use-case was around some functionality I’d prototyped back during the days of Project Refinery, where while exploring the results created during a generative study you could double-click individual designs – whether in the scatterplot or the design grid – which would add them to a graphical dashboard to be used for stakeholder communication. This was (in my ever-humble opinion) super-cool, but remained an exploration rather than making it into a fully fledged feature.
When thinking about how it might be possible to get a workflow such as this functioning with Revit 2021, I speculated that some kind of event – or even something more kludgey such as placing the selected design ID in the Clipboard – would help with this. When I described this to Zach, he pointed me to a feature that’s used to share data with Revit: the Data.Gate node.
Before looking into that, let’s take a step back to consider how GD workflows are implemented using Dynamo. Firstly you need a Dynamo graph with inputs and outputs (flagged with the IsInput and IsOutput option respectively). The “Create Study” UI allows you to control how this graph will be optimised – which inputs to vary (and whether they should be constrained), and whether to minimise, maximise or ignore the various outputs. When the study is started, the optimisation engine will use a headless version of Dynamo (in fact four of these at a time) to execute the graph and generate designs.
It doesn’t make sense to have the headless version of Dynamo call into Revit when it executes the graph, as this could happen many, many times. And in fact headless Dynamo isn’t hosted by Revit and so doesn’t have access to Revit-centric nodes at all. So there needs to be a mechanism that allows data to flow from Revit into the Dynamo graph – perhaps for geometric constraints such as the boundary of a space you want to analyse – but also to allow data to flow back to Revit once a design is selected (typically to create Revit elements based on what’s been generated inside Dynamo).
We have two nodes that help with this data flow:
Data.Remember caches data from a host application so that it’s made available to the graph every time it executes. This is typically used to cache data coming from Revit or AutoCAD Civil 3D today.
Data.Gate allows you to push data back to the host application when the “Create Revit Elements” button is pressed inside the Explore Outcomes UI. When the gate is “Open” – something performed automatically when the button is pressed – the input data flows through it, while when it is “Closed” – which is the default state when the graph is exported for use in the GD feature – the node returns null. So you typically have a set of nodes that take the output of the gate and use it to create Revit elements (or do nothing in the case where it’s null).
Let’s take a look at how Data.Gate is used to generate Revit elements.
Here’s the Explore Outcomes UI showing a recent study:
When we click Create Revit Elements for the selected design – and make sure the visibility settings allow Masses to be displayed, etc. – we see the geometry get created inside Revit:
The Dynamo nodes that make this happen are behind a Data.Gate:
Now these nodes were designed for the purposes I’ve mentioned, but interestingly they both have a lot more scope to be used in interesting ways. For instance, Data.Remember can be used to cache data that would otherwise be generated identically for every execution of the graph, making it execute more efficiently. And Data.Gate can be used to do something interesting with the selected study, such as writing its inputs out to a text file for consumption in another process.
In the next post we’ll explore exactly this workflow: where we use Data.Gate to do something other than creating Revit elements.