Goal: Now that we have some basic familiarity with the new Dynamo Visual Programming environment, let’s use it on a more real-life example. The goal of this exercise is to set up a feedback loop that optimizes the amount of solar radiation incident on the roof of a proposed building. We will use Dynamo to read Solar Insolation analysis results and then make changes to the building model in the form of driving parameters back into a family instance.
As a case study, we will look at a 20,000 sqft building in an urban area. The local climate and state incentives support the use of alternative energy sources to offset building energy consumption. We want to maximize the incident solar radiation on the roof of the building to make the most of a photovoltaic array, but because of some overshadowing by neighboring buildings, it isn't obvious where the "sweet spot" is for solar orientation.
| Parametric Form Creation |
The overall building size must always accommodate 20,000 square feet, but he shape of the building is not yet defined. This family establishes the basic set of constraints, by allowing a full 360 degree rotation of the building form, and maintaining a constant volume for the building, with height being driven by building footprint. This however does not allow us to explore the requirements of rooftop solar optimization
|
Adding Height and Angle control to Mass Family
|
Using the same basic skeleton as the first mass family, we can now manipulate the angle of the roof while maintaining the overall square footage of the building. We have already added parameters for the front and back elevation heights for the building to allow the roof to slope
Formulae to control rotation via increment parameter
The mass we will use has been constructed so that if you change the increment parameter it will rotate the building however many degrees as defined by another parameter, angleIncrement. We will use Dynamo to iteratively rotate the building and find an optimal orientation relative to the sun while taking nearby building overshadowing into account.
>
(Open). 
Set up the Automatic Export for the Solar Radiation results
Solar Radiation Optimizer Sample
11)We will use Dynamo to do a few things:
a) Vary the rotation angle of a building a set number of degrees and run through a set number of increments. This is called a ‘brute force’ approach where every increment is computed first and then evaluated.
b) Read and parse the analysis results from the Solar Radiation tool for each increment. Compute the maximum energy for that increment.
c) Compare the current analysis result to the previous ones, holding onto the maximum value and the parameter that relates to it.
d) Once all iterations are completed and a global maximum is found, update the model to show the optimal state.
e) Below we see a few inputs: the family instance to control, the name of the parameter in the family instance, the maximum increments and the filename of the analysis results CSV file to watch.

Set inputs for the Solar Radiation Optimizer in the Home workspace
The Solar Radiation Optimizer in action – sit back and watch Dynamo automatically find the optimum result!
15)To learn more about how this is set up, we will dig into the user-created nodes below. Double-click on the Solar Radiation Optimizer node and you will see something like this:
Solar Radiation Optimizer - a user-created node to control program flow
16)The Solar Radiation Optimizer node takes in a bunch of inputs:
a) famInst - The mass family instance we are working with
b) parameter - The name of the parameter to vary
c) increment - The current increment value
d) max - The maximum increment value
e) path - And finally the path to the CSV file to watch.
f) The Watch File node is quite important in this example, as it simple watches and waits for the CSV file to update. Once the Solar Radiation tool re-writes this file, the Watch File node is notified. We use this as a trigger to kicks off the next round of the optimization automatically.
g) The solarradopt node is a user-created node. This one actually does the bulk of the work and iterates (or more precisely recurses) through the permutations.
h) The solarradupdate node is another user-created node. This node is responsible for updating the family. Notice how each node has a particular responsibility.
solarradopt - a user-created node to recurse through the rotations
17)The solarradopt node actually does the bulk of the work and recurses through the permutations. It takes in certain inputs:
a) fI - The mass family instance we are working with
b) p - The name of the parameter to vary
c) i - The value to increment by, 1 in this case.
d) max - The maximum increment value
e) amt – the current increment value
f) acc – the previously computed values (initialized to 0 in the outer node). This parameter is a list that holds the computed SR value and the associated iteration number
g) path - the path to the CSV file to watch.
h) Fw – the filewatcher
18)This node processes the CSV file using Read File andExtract Solar Radiation Value and then compares the new value to the previous value using another user-created node called solarradcomp.
19)It also sets the family instance to the current iteration.
20)Notice the node called solarradadopt? Wait, isn’t that the node we are editing right now? This is a concept called recursion, where a function can call itself. We are using this here instead of a for next loop or a do while loop.
solarradcomp compares the two values, old and new
21)The solarradcomp node does what it says, it compares two solar radiation values and returns the larger of the two values. Variable old is a list containing the SR results values and its iteration. Variable data is the new SR data and newAmt is the number of the newest iteration. If data is larger than the data in old, then we return a new list containing data and newAmt.
solarradupdate pushes the final optimal value back into Revit
22)The solarradupdate node does the final updating.The largest value is the only one passed back out from the solarradopt – it recurses through the 36 cases and only holds onto the largest value, passing it back out after each recursion. So the result passed out at the end and into solarradupdate is just a list with two members, the value and the index. The Get node in this case is getting the second member, result[1] which is the increment value of the optimal case, and then we pass in this increment value to the set instance parameter node. The result[0] andresult[1] data are set up when the list is constructed in solarradcomp.
Solar Radiation Sample in action – two addins talking to each other and pushing data back into Revit
These examples demonstrate powerful new visual programming tools on top of Vasari and Revit. These examples also show a hybrid application of custom tools and standard smart Revit/Vasari components with Vasari’s Analysis tools. While these tools are more than a little rough around the edges, we hope that they are convincing indicators of several things: