Join Paul F. Aubin for an in-depth discussion in this video Add length and width to a room tag using Dynamo, part of Revit: Tips, Tricks, and Troubleshooting.
- [Instructor] In the last two tips in this series we've looked at a few different alternative ways to add the length and width of rooms to the labels within the room tag. The first approach that we looked at was to add the information completely manually and, as you would expect, adding the information manually is quite tedious and prone to error. So last week we looked at taking that manual information and replacing it with information that came from reporting global parameters and that was a valuable approach because it automatically reacts to changes in the model, but there's still a somewhat tedious set up process required to get that solution going.
This week what I'd like to do is look at another alternative using Dynamo. Dynamo is a visual programming interface that's built right into Revit and allows you to access programmatic functions and so what we're going to do is using Dynamo we'll build a simple graph that will read all of the room elements in our model, figure out what their lengths and widths are, and then automatically push that information back to the Revit geometry. So let's go ahead and get started here. On the manage tab I'll click the Dynamo button here and that will launch the Dynamo interface.
Dynamo runs as a separate application, but it's tethered back to the Revit instance that you have running. So our Revit model in the background will be linked to this new graph that I'm creating, so I'll click new there. Now the first step is going to be to grab a selection of all of the room elements, so under the Revit branch in my library, under selection, I'll choose the all elements of category node in the categories node. Now I'll take the categories node and put it to the left and click the out port of that node and wire it up to the in port of the category node here.
Then using this drop down I'll type the letter R just to scroll down on the list and then scroll down further until we find the rooms category and select it. As soon as I do that, you'll see here on this small information bubble that we have 16 room elements compiled in a list. Now, if you take Dynamo and move it out of the way and click any one of these green numbers here, these are actually linked to specific room elements in the Revit model and you'll see that it will jump to the corresponding element.
So let me go ahead and move Dynamo back into the foreground and let's continue. So we now have our 16 rooms. The next thing that I want to do is find the boundary of those rooms, so I'll close the selection branch here and scroll down to the elements branch and then rooms and here we have several ways that we can query the room elements. I'll choose this one by finished boundary.
So this is looking for a list of rooms, which we have right here so I'll feed that in, and you'll see in the background that it traces all of those rooms and creates a collection of curves. Now, in Dynamo a curve is any linear path, so it could be a curvy curve or it could be a straight curve. So a straight line is considered a curve. So in this case we have a series of straight lines, but that's a collection of curves. Now we also have what we call a structured list, so this list zero here corresponds to a single room in the model.
Now if I want to get a better look at that model I can use these icons at the top to navigate the background preview and orbit it slightly so that I can see down onto that floor plan. Now that's the bedroom in the lower left hand corner that I have selected. The next space over is listed here and so on. So what I want to do is instead of all these separate lines, so here on list zero I have nine separate lines, zero through eight.
I want to take those nine separate lines and I want to put them together into a single element called a polycurve. Now, if you want to browse for where that is you can continue to use the library here and it's under the geometry branch, but you can also type in the name of the element on the search field here and it will filter the list to those elements that contain that search word. So in this case I'm going to search for polycurve and scroll down and I'm looking for a polycurve by joined curves.
So what that's going to do is just connect together all these separate lines into individual polycurves. Now notice that I'm back to 16 elements, but I still have a structured list. So you notice here how I have list zero and it contains a single item, then list one and it contains a single item, and so on. I don't need that structure in the list at the moment so I'll search for another node here called flatten and what that will do is it will remove all of the structure from the list and leave me with just 16 polycurves.
Now, the next node I want to use is not one of the built in nodes in Dynamo, it's one that comes from what we call a package. So if you look at the packages menu here, you can go to search for package, and the package I want to search for is a very popular one called spring nodes. So if you just start typing the word spring, you'll see spring nodes here and you can use this little down arrow here to install the package. Now, I've already got it installed here in my Dynamo right there, it's this springs entry, so I'm not going to download it, but if you don't have spring nodes installed then go ahead and download it and install it and then once you do, you'll be able to search for a node called Springs.Geometry.Extents.
So this is a really terrific node that will take any geometry you feed it, in this case our 16 polycurves, and it will output exactly what we need with length and it actually outputs the height as well. Now if you expand your information bubble here, you'll see that we again get a list of lists and each list contains the width, the length, and the height. Now we're not really interested in the heights at the moment so I'm going to focus on the lengths and widths.
Well notice here that the spring node actually has separate outputs for those values, so it's always a pretty good idea to double check this, so we can do that with a watch node and what I'll do is I'll add two watch nodes. One for the widths and another one for the lengths and you'll see them coming out right there. So if we expand this information bubble once again you'll see that item one contains the first entry at 15.16 units, the second entry at 11.33, notice here 15.16, 11.33.
So all of our lengths are on this list, all of our widths are on this list. So now we have the information that we were looking for. All we need to do now is push that information back into Revit. So when you want to either pull information out of Revit or push it back to Revit, you can use one of two nodes called either get or set parameter by name. So under Revit, under elements, plural, and then element, singular, you will find those two nodes.
Get parameter value by name, set parameter value by name. Since we're trying to write information to Revit, we're going to use set parameter value by name and I'll bring in two of those since we need to do both length and width. Now, back in Revit, if we select one of the rooms, recall that the names of the parameters we're trying to write to are called room length and room width with uppercase letters at the start of each word, therefore you need to type the names of those parameters exactly the way they appear in Revit.
So I'm going to come up here to the top of the library under core, under input, and bring in two string nodes. String nodes are just text fields, so when you want to just type in a text value, you can use a string, and I'll type in room length, again using exactly the same case, and room width. I'll wire this one here and this one here. For the values, just make sure you're putting in the right ones, so here's the width coming to this watch node so I'll feed that over here.
Here's the length coming to this watch node, I'll feed that over here. And what about the elements? Well the elements come way back here. The original collection of rooms that we gathered from Revit in the first place. So I'll take that element list and feed it in here and then do it again and feed it in right there. Now down here, I'm executing my graph automatically, which means it's already processed the information and it's already fed this information back to Revit.
So let me minimize and show you the result. Notice that all of my room tags have already filled in with the length and width values. If you open up the schedule, you'll see all the information appears there as well. Now if you wish, you can go in and do a few more nodes and grab the height information and then use another set node to push that information back into the rooms from either the rooms themselves or from the ceiling elements.
So I'll leave that to you as a challenge exercise, but the process would be exactly the same as what we just looked at. So as you can see, there's a few different approaches that we can take to adding length and width information to our room tags, but I think the Dynamo approach is by far the most automated of the three and anytime that you need to update the information, you just simply run the Dynamo script again and it will update all the values for you.
NOTE: The exercise files for this course can only be opened in the most recent version of Revit (Revit 2017).
Skill Level Appropriate for all
Q: Why can't I earn a Certificate of Completion for this course?
A: We publish a new tutorial or tutorials for this course on a regular basis. We are unable to offer a Certificate of Completion because it is an ever-evolving course that is not designed to be completed. Check back often for new movies.