Animating almost anything in Revit using Dynamo.

As amazing as Autodesk Revit is for modeling and documenting a building, there is no question of the fact that it’s not exactly the strongest when it comes to animation. in this tutorial, we’ll go over a few techniques within Dynamo that will allow us to animate “almost” anything in Revit. now I should also mention the fact that not everything is programmatically adjustable in Revit but the general convention is that if you can edit something in the user interface, then you’ll probably be able to animate it (of course there might be exceptions to this; hence the word “almost” in the title of this blog post).

If all you wanna do is to create a simple walk-through by animating the camera and it’s target, then it would be foolish not to use the builtin walk-through creation tools offered by Revit. but if you’re after something more specific with a greater level of control of the parameters of every family instance, then this tutorial is for you. I should also point out that the methodology described here is very much inspired by a custom Dynamo package called Dynanimator which is developed by BadMonkeysTeam. although you do not need to install the package in order to be able to follow along with this tutorial, keep in mind that the general approach that’s explained here is borrowed from Dynanimator and is modified to suit our needs. feel free to download and install this excellent package and experiment with it. now without further ado, let us get started.


Steps:

  • creation of the animation_function node.
  • Creation of the animation node.
  • assembling the graph and feeding in the required information.

Step 1: “animation_function” node

this is the heart of the code, this is where we define our rules and every time that we wish to re-purpose our graph to animate something else, we’ll do it here. the big idea is that, we’ll lay the ground work of the changes that we’ll be making to the model here with a simple twist, we want the changes to happen one after the other for every single iteration (frame). so the general order of execution is as follows:

  • read which iteration we’re at.
  • read the input information.
  • execute change number 1.
  • execute change number 2.
  • execute change number 3, 4 etc….
  • and finally execute the last command: exporting the frame to a user-defined directory with proper naming.

the changes can be anything, this is exactly why this method is so useful, we have so much freedom over what is required to be animated and how. please keep in mind that the changes should be governed by the “iteration” value since we’re trying to generate the frames of an animation. for the purposes of this demonstration, we’ll be animating “object rotation” but the same principles with minor tweaks and changes can be applied to animate other aspect of the model, here is the graph for animation_function.dyf:

animation_function.dyf custom node
  • Input nodes: element, iterations, step, angle, view, path.
  • Change #1: rotating the instance based on this particular time-step. we determine the angle of each iteration based on a few factors (total number of iterations, current step and user defined angle). this is the formula: 1 / iteration * step * angle.
  • Final command: exporting the frame: here we use String.Concat to assemble a string variable using some of our input nodes, notice that the “step” input node is used to make the names varied and thus prevent overwriting of files during the export process. this also makes it easy to find particular frames later on.
  • We plug the last node of every action into a Transaction.End node to close their transactions. we finally feed those into a Function Compose node.

Step 2: “animation” node

there is really nothing special about this node, all that it ever does, is prepare the input information and iteratively run a given function (animation function node) for a total of n times. with n being the user-defined number of iteration or in other words the total number of frames in the whole animation. here is the graph for the custom node animation.dyf:

animation.dyf custom node
  • Input nodes: iteration, angle, element, path, view.
  • Here we place our animation_function custom node that we just created. notice how every slot has a corresponding input assigned to it except for “step”. leaving this argument unassigned turns our node into a function which can then be applied to a range of values using a List.Map node.
  • Outputting the results using an Output node.

Congratulations! our custom Dynamo node is now finished! all that is left to do is to feed in the required input arguments and click enter. a series of .png files will be exported to our defined directory which can then be processed into a video file quite easily:

using the custom node “animation” that we just created.
Rotation animation (demonstrated in this post)
animating family parameters