Dynamo for Revit – Bill Knittle, Synergis

31
1 Dynamo for Revit® Contents Dynamo for Revit® ......................................................................................... 1 Introduction .............................................................................................. 2 The User Interface....................................................................................... 3 Understanding Visual Programming ................................................................... 5 Nodes ................................................................................................... 6 Lists ..................................................................................................... 7 Practical Examples ...................................................................................... 8 Architectural: Renumbering Rooms ................................................................ 8 Structural: Converting Linked/Imported CAD Gridlines to Revit Grids ....................... 17 MEP: Specified Supply Airflow of a Space to its Supply Air Terminals........................ 21

Transcript of Dynamo for Revit – Bill Knittle, Synergis

Page 1: Dynamo for Revit – Bill Knittle, Synergis

1

Dynamo for Revit®

Contents Dynamo for Revit® ......................................................................................... 1

Introduction .............................................................................................. 2

The User Interface ....................................................................................... 3

Understanding Visual Programming ................................................................... 5

Nodes ................................................................................................... 6

Lists ..................................................................................................... 7

Practical Examples ...................................................................................... 8

Architectural: Renumbering Rooms ................................................................ 8

Structural: Converting Linked/Imported CAD Gridlines to Revit Grids ....................... 17

MEP: Specified Supply Airflow of a Space to its Supply Air Terminals ........................ 21

Page 2: Dynamo for Revit – Bill Knittle, Synergis

2

Introduction Autodesk® Revit® has gained wide-spread acceptance across the AEC (Architecture,

Engineering, and Construction) industry as the de facto solution for Building Information

Modeling. Simply put, a Revit® project is a relational database which is manipulated via

Revit’s powerful parametric modeling engine. Although Revit® has very powerful design,

documentation, and analytical tools it may feel tedious or laborious to facilitate certain

activities. In an effort to increase the productivity and performance of tasks, some companies

have turned to custom programmers to create text code that can ease many of these

software pains. Unfortunately, many companies do not have the resources to hire such an

individual or in some cases, fill a spot vacated by such an individual. This is where Dynamo

becomes very appealing. Dynamo is a visual programming application that empowers

designers with little or no programming experience to use visual logic to create, manipulate,

and explore their own parametric conceptual designs or, use it to interface with other

databases to automate tasks.

In this session, we will ignore the computational design side of Dynamo

and explore the daily practical side of it, automation. What I mean is

that we will use Dynamo to interact with the API (Application

Programming Interface) of Revit to automate those time-consuming

tasks. Firstly, you will need a brief overview of Dynamo’s interface and

basic functionality. Dynamo is accessed from within Revit 2017 via the

Manage tab. The Dynamo button can be found on the Visual

Programming panel to the far right of the Manage ribbon.

Page 3: Dynamo for Revit – Bill Knittle, Synergis

3

The User Interface Once the Dynamo button is selected within your Revit project, Dynamo will launch and run

concurrently with your Revit 2017 session. If you have the means, dual monitors are a must!

When it is open Dynamo will display to the user its Start page. The Start Page is broken down

into several distinct areas of shortcuts which are based on function. In the following image,

study the locations of the various shortcuts to become acclimated to their location.

In most cases, you will be either starting a new file or, you will be opening a recent file. To

learn more about Dynamo, you can utilize the Samples, Ask, Reference, and Code shortcuts.

Page 4: Dynamo for Revit – Bill Knittle, Synergis

4

Selecting New in the Files shortcuts will launch a new Dynamo Workspace. The Dynamo

workspace is simple and easy to navigate. Dynamo’s UI (User Interface) is made up of the

menu bar, toolbar, library of nodes, workspace, and execution bar. In the following image,

study the locations of the various UI parts to become acclimated to their location.

The Workspace canvas is highly immersive and interactive. Dynamo’s Workspace provides two

modes of accessing your design or programs within the Workspace. The default mode is the

Graph Preview. The Graph Preview mode allows you to interact with your visual code as you

develop it. Dynamo is also a parametric modeling tool. It creates or reads 3D surfaces and

geometric forms. The 3D Preview mode allows you to interact with the Dynamo geometry you

created or referenced. The toggles are located in the upper-right corner of the workspace.

You can also right mouse click in the Graph Preview or 3D Preview mode to access the toggle

within the Context Menu or, if you can select Ctrl+B if you are a keyboard shortcut kind user.

Page 5: Dynamo for Revit – Bill Knittle, Synergis

5

Along with the interface comes mouse interactions. The table below indicates the various

actions and how they work within each preview mode.

Understanding Visual Programming When beginning in Dynamo think of it as a tool to create a

flow chart of logic. In the image on the right, there are

several shapes in the chart which indicate a specific

function. These shapes in Dynamo are called Nodes. Nodes

will typically create, query, or perform an action. Like

the image on the right, Nodes can have one or multiple

inputs and outputs. The arrows in the image on the right

show the direction of flow in the logic of the chart. In

Dynamo these are called Wires. The Wires connect the

input and outputs of the Nodes to create the flow of logic

in the graph. Wires are simply created by depressing the

left mouse button over an output of one Node and

releasing it over the input of another Node. When Nodes

are finally wired together, they create the visual

program.

At left, is a simple graph. It takes

two Number Nodes with different

values and wires them to an

Addition Node. To see the results,

a Watch Node was added. You can

see that the two Number Nodes

are grouped together. In the

Addition Node the List button has

been selected to display the sum.

Above the Addition Node you can

see a Note to describe the

function. As you can see, Dynamo

provides a visually simple means to

define various functions.

Page 6: Dynamo for Revit – Bill Knittle, Synergis

6

Nodes In order to start placing Nodes, we must first explore where to find them. Nodes are located

in the Library located on the left of the screen. The Library can be rolled up or rolled out.

Here users can browse the list of Node Libraries their subset of Categories of Nodes and in

some case, their Subcategories (sounds Revit-ish).

To help locate Nodes in this vast Library users can take advantage of

a search bar located at the top and type the Node’s name. The user

can also click the right mouse button in the workspace to launch a

context menu which also includes a search bar for locating Nodes.

Given that Dynamo is open-source, users are also creating custom

Nodes which they share openly as Packages. Packages can be

downloaded from the Packages menu directly into Dynamo. They

come filled with custom Nodes created by other Dynamo users.

Packages can be accessed from the Packages menu on the menu bar.

As a beginner, you will learn the location of Dynamo Nodes through the use of the Search bar.

More often than not, the name of the node is going to indicate the Category it is part of. For

example, the List.Create Node is going to be found in the List category. The Library it’s a part

of is not so easy to determine. These are the lessons of learning a new application I guess.

Page 7: Dynamo for Revit – Bill Knittle, Synergis

7

Lists The next essential aspect of Dynamo is Lists. Lists are collections of data or

items. When you create data in Dynamo or pull data from Revit, a List is

generated listing all the data. What is interesting about Lists in Dynamo is

that the first item is indexed as 0. So, a list of 10 items 1 – 10 would be

indexed as 0 – 9 in Dynamo. Therefore, it is important to understand Lists in

Dynamo and how to access them, manage them, and use them to maximize

your needs.

In some cases, your Lists will be confusing. For

example, you may query or create two elements

that and combine them. If the number of indices

in one list differs than the number of indices in the

other you run into a lacing issue. There are three

ways to combat this issue. It’s called Lacing.

Lacing is accessed by clicking the right mouse

button over the lower-right corner of the Node.

Think of Lacing as in lacing up your shoes. There

are several ways one can lace up a pair of shoes.

Dynamo is no different.

Below, Dynamo is being used to generate Cartesian Points. One list has 5 indices and the

other 7. As you can see, they are wired as x and y coordinates in the Point.ByCoordinates

Node. Lacing on this Node set to Shortest. Shortest is the default Lacing in Dynamo.

Eventually the second list runs out of indices with the first list dropping off two points. Lacing

set to Longest on the same Node ends up re-using the two remaining points on the second list.

With the Node set to Cross Product it uses every possible combination between the two lists.

Page 8: Dynamo for Revit – Bill Knittle, Synergis

8

Now that we know a little bit more about Dynamo, let’s get programming! We will go through

several practical architectural, structural, and MEP examples of how you can use Dynamo to

make everyday tasks that are laborious a leisurely walk in the park. With each example you

will walk through the logic of each step so that you understand how Dynamo works and

operates with a Revit project database.

Practical Examples

Architectural: Renumbering Rooms I’m sure that you’ve come across numerous scenarios

in Revit where you just wished it was easier to do.

For instance, we have all been down the road of

renumbering rooms in our Revit architectural design.

The more rooms… The more the joy…. That was

sarcasm by the way. As we all know, we have to

select the instance of a room and change its Number

parameter value. If there is a room instance with that number, Revit is sure to tell us! As you

may or may not know, Revit 2016 introduced us with a new room placement option called

Place Rooms Automatically. Great! But, Revit doesn’t know what order I want them to be

numbered in when it places them. Sure, that places the room instances quicker but now, it’s

made more work for us to renumber them.

Page 9: Dynamo for Revit – Bill Knittle, Synergis

9

Well, what if we used Dynamo to renumber our rooms for us. One of the interesting things

that Dynamo can do with our existing Revit model is understand the relationships between the

geometric elements. In this case, we’ll use a Model Line as a path to walk our renumbering

logic through the rooms so that they sequence themselves in the correct order.

A Model Line is 3-dimensional and can weave

and bend when drawn as a single Spline. The

start and end of the Spline is important. I will

begin the Spline in the lower-right room and

make a simple U-shape through my floorplan

making sure to intersect each room instance.

Now, we can begin programming. The Spline that we’ve drawn is a curve in the eyes of

Dynamo. Therefore, we must add a Node from the Node Library that allows us to manually

select the Spline within Revit model. The Select Model Element is just the Node for the job.

To generate the Spline in Revit as a Curve in Dynamo, we will use the CurveElement.Curve

Node. This will draw the selected Spline within the Dynamo Workspace. Depressing the left

mouse button over the output of the first Node, we can create a wire connecting it to the

input of the second Node by releasing the left mouse button.

Page 10: Dynamo for Revit – Bill Knittle, Synergis

10

Now, we must acquire the room instances from our Revit model. To do this we will use the

Categories Node and wire it to the All Elements of Category Node. Within the Category Node

we can use the drop-down to select the Rooms category from our Revit model.

Acquiring just the rooms is not enough. Therefore, we must obtain something tangible such as

the room’s bounding box. We’ll add the Geometry.BoundingBox Node and wire the output of

the All Elements of Category Node to the input of the Geometry.BoundingBox Node.

Expanding the List of the last Node we added reveals the points for each corner of each room

instance.

Page 11: Dynamo for Revit – Bill Knittle, Synergis

11

Now that we have the geometries in Dynamo, we can begin to compare their relationships.

Firstly, we need to segment the curve into equal segments. To do this, we’ll add the

Curve.DivideEqually Node and wire the output of the CurveElement.Curve Node to the

“curve” input of the Curve.DivideEqually Node. Secondly, we’ll add the Integer Slider Node

to control the amount of divisions we need. We’ll wire the output of the Integer Slider Node

to the “division” input on the Curve.DivideEqually Node. Using the menu arrow on the Node,

we can enter a Min value of 0, Max value of 400, and a Step of 1.

Page 12: Dynamo for Revit – Bill Knittle, Synergis

12

To complete the logic in the curve, we must have Dynamo determine the end points of each

of the 400 segments in the curve. We’ll add the Curve.EndPoint Node and wire the output of

the Curve.DivideEqually Node to the input of the Curve.EndPoint Node. Using the List, we

can review each of the 400 end points in the segments of the curve.

The next stage of our program needs to confirm if the end points that we’ve isolated are

contained in the bounding boxes of each room instance. For this task we’ll add the

BoundingBox.Contains Node. We’ll wire the output of the Geometry.BoundingBox Node to

the input of the BoundingBox.Contains Node. This Node will serve a single function and not

require the use of its other input. The logic we’ve just connected will return a list of

True/False responses. As a result, we’ll need to compare it with the list of endpoints to see

which points are contained within the bounding box of each room instance. We’ll add the

List.Map Node to generate a new list of each endpoint and whether it is contained “True” or

is not contained “False.” We’ll first wire the output of the Curve.EndPoint Node to the “list”

input on the List.Map Node. Then, we’ll wire the output of the BoundingBox.Curve Node to

the “f(x)” input on the List.Map Node.

Page 13: Dynamo for Revit – Bill Knittle, Synergis

13

In our case, we only care about the “True” points. Therefore, we’ll add another List.Map

Node. We’ll also add the List.FilterByBoolMask Node to help generate a list of endpoints that

throw back a “True” result. We’ll wire the output of the All Elements of Category to the

“list” input on the List.FilterByBoolMask Node. Then, we’ll wire the “in” output of the

List.FilterByBoolMask Node to the “f(x)” input on the new List.Map Node. Finally, we’ll wire

the output on the previous List.Map Node to the “list” input on the new List.Map Node.

Unfortunately, the list is indexed too much. We’ll need to simplify it. Therefore, we’ll add

the Flatten Node to accomplish this. Adding a wire from the output of the open List.Map

Node and the input of the Flatten Node does the trick.

Page 14: Dynamo for Revit – Bill Knittle, Synergis

14

All that’s left to do is to tell Dynamo how to sequence the number of the room instances.

Unfortunately, our flattened list of points has many duplicates. Therefore, we’ll need to

weed out the redundant points. To do this, we’ll add the List.UniqueItems Node. We can

wire the output of the Flatten Node to the input of the List.UniqueItems Node.

Page 15: Dynamo for Revit – Bill Knittle, Synergis

15

To generate our numbering scheme, we’ll need the help of several Nodes. Let’s add two

Number Nodes, a Count node, the Sequence Node and, the String from Object Node.

We’ll enter 101 into the first Number Node and wire it to the “start” input of the Sequence

Node. Then, we’ll enter 1 into the second Number Node and wire it to the “step” input of

the Sequence Node. Next, we’ll wire the output of the List.UniqueItems Node to the input

on the Count Node. After that, we’ll need to wire the output of the Count Node to the

“amount” input of the Sequence Node. Finally, we’ll take the output of the Sequence Node

and wire it to the input of the String from Object Node. This Node converts the object to

string values which will be crucial to inputting new numbers back into Revit.

Page 16: Dynamo for Revit – Bill Knittle, Synergis

16

All that’s left to do is to feed the values back into the rooms of our Revit model. Therefore,

we will add String Node and an Element.SetParameterByName Node. We’ll wire the output

of String from Object Node into the “value” input of the Element.SetParameterByName

Node. Then, we’ll enter “Number” into the String Node to set the value of the each room’s

number instance parameter. We’ll wire the String Node into the “parameterName” input of

the Element.SetParameterByName Node. To complete the circle, we’ll wire the output of

the List.UniqueItems Node into the “element” input of the Element.SetParametersByName

Node. This will backfeed the numbering sequence back into the rooms to overwrite the

previous values.

The results are automatically visible in Revit.

Page 17: Dynamo for Revit – Bill Knittle, Synergis

17

Structural: Converting Linked/Imported CAD Gridlines to Revit Grids So, you still have those CAD files and have to work with them in Revit. Don’t despair. Get

even… with Dynamo. Converting CAD lines to Revit elements is nothing new. For instance, you

can use the Pick Lines option within the Grids command. However, who has time to

click…click…click… on CAD lines one-by-one. Let’s look at how Dynamo can do this in one

click. First thing to realize though, is that we are working with Layers. In order for this to

work, we will first link in the CAD file by specifying the Layer the CAD gridlines are on.

In the case of this example, we are ignoring coordinates

and just bringing the CAD file in Auto – Center to Center.

We could always go back and discuss coordinates another

day. We’re under a deadline to generate grids at a blink of

an eye here!

By specifying the Layer we want, only that layer will link

into our Revit project. Fortunately enough, the grids were

all drawn on the correct layer. Good job CAD drafter!!!

Now, on to the good stuff. We’ll accept the layer and link

in the drawing file as an import CAD symbol.

Page 18: Dynamo for Revit – Bill Knittle, Synergis

18

As a result of our efforts, there are now only gridlines linked into Revit. So far so good!

Dynamo’s turn! To Dynamo, the CAD link is a Model Element Document. Therefore, we will

use the Select Model Element Node. This Node will allow us to select the CAD link within the

Revit view.

Page 19: Dynamo for Revit – Bill Knittle, Synergis

19

Now, we need to convert the selected document into curves. To do this, we will add the

Element.Curves Node. Wiring the output of the Select Model Element Node to the input of

the Element.Curves Node generates the grids inside the Dynamo Workspace.

With the geometry in Dynamo, we need to define its limits so that we can program Dynamo to

recreate the curves as Grids back in Revit. We’ll add the Curve.StartPoint and

Curve.EndPoint Nodes. Next, we’ll wire the output of the Element.Curves Node to the

inputs on the Curve.StartPoint and Curve.EndPoint Nodes.

Page 20: Dynamo for Revit – Bill Knittle, Synergis

20

All that’s left to do, is push the Dynamo curves into Revit as Grids. We’ll add

Grid.ByStartPointEndPoint Node. Finally, we’ll wire the outlets of the Curve.StartPoint

Node to the “start” input on the Grid.ByStartPointEndPoint Node and the output of the

Curve.EndPoint Nodesto the “end” input on the Grid.ByStartPointEndPoint Node. Danger!

Look out for elbows at the grid bubbles. This may create errors in Dynamo and small Grids in

Revit. No worries…just delete the little buggers.

Page 21: Dynamo for Revit – Bill Knittle, Synergis

21

If we shift back to Revit, Revit Grids! Voila!

MEP: Specified Supply Airflow of a Space to its Supply Air Terminals Here’s another one I’m sure my mechanical friends have encountered, determining how to

distribute the specified supply airflow for a Space amongst the Air Terminals in the room. Not

so daunting right? Heck… that’s what engineers… I mean Excel… I mean calculators are for!!!

Who has time to wait for them though! We have Dynamo. Let’s begin with the Space. Our

trusty engineers have concluded that the specified supply airflows of our Spaces are entered

in the model from their analysis. Wouldn’t you know it, the modelers came through too and

peppered the model with Air Terminals. All of which are pumping in 500 CFM. To compound

the issue, the supply Air Terminals are not the only Air Terminals in the model. So, our

specified and actual flows are all wacky. Not for Dynamo! Hold on tight, this is a long one.

Page 22: Dynamo for Revit – Bill Knittle, Synergis

22

This exercise will work best with Dynamo executing in the Manual

mode. Firstly, we need to get the Spaces from the model into Dynamo.

Nothing new, we’ll just add the Select Model Element Node. In the

Revit, we can select the first Space to see its ID in Dynamo.

Next, we’ll get those Air

Terminals. To do that, we’ll add

the Categories and All Elements

of Category Nodes. Then, we’ll

wire the output of the Category

Node to the input of the All

Elements of Category Node.

Let’s specify Duct Terminals for

the Categories Node. This will list

both the supply and return Air

Terminals. We’ll have to isolate

the supply from the return

shortly. But for now, let’s see if

we get any intersecting

geometry. We’ll have to select

Run to get the results from now

on.

Page 23: Dynamo for Revit – Bill Knittle, Synergis

23

First, we have to get the geometry of the Spaces as well as, the geometry of the Air

Terminals from Revit into Dynamo. Therefore, let’s add two Element.Geometry Nodes and

wire one up to each of the All Elements of Category Nodes. By selecting the Node in the

graph view, it highlights the elements in the 3D view of the Workspace. Don’t worry. I haven’t

forgotten about those return diffusers. We’ll get them out of there soon enough. Run!

To check for their intersections we’ll add the Geometry.DoesIntersect Node. We’ll wire up

the outputs on the Element.Geometry Nodes to the corresponding inputs on the Geometry

DoesIntersect Node. Once complete, we can review the list. Reviewing the list, we can see

that it is using the Shortest Lacing. So, we’ll set it to Cross Product! Much better! Run!

Page 24: Dynamo for Revit – Bill Knittle, Synergis

24

Since we have a list within a list, we’ll flatten to a single list. We’ll add the Flatten Node and

wire its input from the output of the Geometry.DoesIntersect Node. Checking the list, it’s

simplified! Run!

No, we want the truth! We’ll add a List.FIlterBoolMask Node. Then, we’ll wire the output of

the Flatten Node to both the “list” and “mask” inputs of the List.FilterBoolMask Node. And

the trues are now separated from the falses! Run!

Page 25: Dynamo for Revit – Bill Knittle, Synergis

25

At this Point, we need to count the beans. I mean… Air Terminals. Let’s add the Count Node

and wire its input from the “in” output of the List.FilterBoolMask Node. Run!

OK. Let’s return back to the Spaces and get those supply airflows. We need Dynamo to

extract parameter values from the “Specified Supply Airflow” parameter. Let’s add the

Element.GetParameterValueByName Node and wire its input from the output of the Select

Model Element Node. Run!

We need to tell Dynamo which parameter now. So, we’ll add the String Node and enter

“Specified Supply Airflow” in the field. Run!

Page 26: Dynamo for Revit – Bill Knittle, Synergis

26

Unfortunately, Dynamo does not read CFM (cubic feet per minute.) It strips out the time and

reads values in ft3. So, when you list the value, you will not see 200 CFM. Run!

We can add a Multiplies Node and Number Node. If we wire them up and set the value to 60

(seconds) in the Number Node we get 200. Run!

Now, we have to divide the Specified Supply Airflow value by the number Air Terminals. Let’s

add a Divides Node and wire its inputs from the outputs of the Multiples and Count Nodes.

Run!

To get the value back to ft3 we can add another Divides Node and String Node to divide the

value by 60 (seconds.) We’ll wire them together. Run!

Page 27: Dynamo for Revit – Bill Knittle, Synergis

27

Darn it! We forgot to eliminate those pesky return Diffusers. No problem. We can add another

set of Element.GetParameterValueByName and String Nodes by copying the ones we have

and pasting them in. We’ll need to unhook the Element.GetParameterValueByName Node’s

“Element” input and connect it from the Duct Terminals. Run!

We only want Supply Air. So, we need to weed them out! We’ll add an Equal and String Node

to the party! We’ll wire them together and enter “Supply Air” into the String Node. Run!

Page 28: Dynamo for Revit – Bill Knittle, Synergis

28

We can copy the List.FilterByBoolMask Node and re-wire its inputs from the output of the

Equal Node. Run!

Again, we are at a fork in the road. So, we need to copy the Equal Node and re-wire it’s

inputs from the “in” output on the last List.FilterByBoolMask Node. We’ll temporarily unhook

the mask wire from the output of the Flatten Node and connect it to the “x” input on the

Equal Node. Lastly, Lets wire the output of the new Equal Node to the newly open “mask”

input on the List.FilterByBoolMask Node. The list for the Count Node now reads 4 and the

flow in the Divides Node is 50. Run!

Now, we can get the results back into the supply Air Terminals we’ve isolated as part of the

selected Space. This requires us to set a parameter value in the Air Terminal called Flow.

Let’s begin by adding a Set.ParameterValueByName and String Node. Then, we’ll wire the

output of the Divides Node to the “value” input of the Set.ParameterValueByName Node.

Next we’ll wire the String Node to the “parameterName” input of the

Set.ParameterValueByName Node. Run!

Page 29: Dynamo for Revit – Bill Knittle, Synergis

29

We also need to make sure only the supply Air Terminals in the selected Space are updated.

We can copy the List.FilterByBoolMask Node again. Then, we can reassign its “mask” input to

be wired from the output of the Flatten Node. Run!

To complete the loop, we wire the “list” input of the List.FilterByBoolMask Node from the

output of the Duct Terminal’s All Elements of Category Node. Run!

Page 30: Dynamo for Revit – Bill Knittle, Synergis

30

If we Run the program, oh-yeah!

We can verify through the schedule in Revit that the airflows are updating as we select each

Space and Run the program. Note, give Dynamo a few seconds in between Space selections.

I have to give credit where credit is deserved! These guys have taught me a lot about Dynamo

and have given me all kinds of ides! They can probably do the same for you. Check out these

links to further your learning.

Dynamo: http://dynamobim.org/

Drew Jarvis: https://knowledge.autodesk.com/support/revit-products/getting-

started/caas/screencast/Main/Details/a4a4d86e-5951-4a5d-b294-7c9386f51c2d.html

William Wong: http://www.case-inc.com/node/497.html

Marcello Sgambelluri: http://therevitcomplex.blogspot.com/2015/10/create-revit-grids-from-

importedlinked.html

Page 31: Dynamo for Revit – Bill Knittle, Synergis

31