One of the keys to making graphs that are flexible is selecting elements parametrically. When you select elements by criteria instead of directly in the UI, the selection can adjust automatically whenever you run the graph.
- [Instructor] So the goal in this chapter is to create a script that looks at the list of views in my project and locates which ones are already placed on sheets, and then if they're on the sheets it's going to rename those views using all upper case letters. The first thing that we're going to do is select all of the views within our project. We want do this parametrically. In other words, we want to choose nodes that will go in and react to the current condition of the projects. So I have a project called Sheet Views open in the background.
There are already several sheets and several views in that file. What I want Dynamo to do is to grab all of the views that are currently there. The nice things about building the graph that way is that when the project changes, you'll be able to run the graph again, and it will just react to any changes you've made. So if you've added views or removed views, it will update all of those lists. And that's really one of the main values of working with something like Dynamo so that we don't have to do all this manually. So let's create a new graph. I'll just click New here in the Start screen. The first thing I want to do is under Revit, under Selection, I want to look at some of the options that we have available.
Now in the previous chapter we used the Select options. Those are fine, but they're not parametric. In other words, it requires you to interact with the graph and personally make a selection in the Revit interface. It's really useful when you need something very specific. That could be the most efficient way to make that selection. But in our case because we want to gather all of the views, we want to approach selection a little bit differently. That's what all of these different nodes up here allow us to do. I'm going to grab this node right here, All Elements of Category.
Now that's literally going to look at the model and find all the elements that belong to a certain category. Notice it's got one input, and it's the category that you want to input there. So here's another node here called Categories. If you open up that list, this contains a complete list of every category in Revit. Now there's things in this list that you didn't even know existed. It's a very long list and you can see here with the scroll bar that it would take you a while. So what you can do is actually just type the letter V, and that will jump down to the first V item on the list.
Then we can continue to scroll, and it's Views that we want to choose. Then I'll wire that in right here. Now we're set to Automatic, so it should already generate some results, and notice that I've got a list here of 47 views. Some of these have the little ID indicators here, and you could click on that theoretically to select something in the Revit model. But because it's not a model element, the result won't necessarily be what you expect. So I'm not going to click on any of those.
Now this is the complete list of views, but what we need to do is filter out from this list anything that's not already on a sheet. We have to think about a way that we're going to do that. Each view has several parameters, and one of the things we can do with Dynamo is we can use a node called GetParameterValuebyName; and we can ask it for certain values. That node is under Elements, and then Element.
Or you can just search for GetParameterValueByName. This is one of the most commonly used nodes in Dynamo graphs because it's so completely useful. You feed in a list of elements here and the parameter name you want, and it will output a list of all the current values of those parameters. Now to feed in the parameter name we're going to use either a string node or a code block. It really doesn't make much difference which one you choose. I personally am just going to go with a string node here because I think it's pretty simple and straight-forward.
But a lot of folks prefer to do a code block. I'm going to wire that into the parameter name. The thing is, we need to know what parameter we're searching for. You have to type it exactly. So let's just click over here into Revit and scroll down and locate one of our views like maybe the north elevation. I'm pretty sure that the north elevation is already on a sheet. So I'm going to select that and look at its properties. Now here's all the different properties that we can look for in the Dynamo graph. What I'm looking for is something that will uniquely identify this thing as being on a sheet, and Sheet Number looks like a great option.
This Sheet Number value would be empty if we didn't have this view anywhere on a sheet, right? So it's Sheet Number with upper case Sheet and upper case Number. So I'm going to type in Sheet Number. Then I'm going to take my list of elements and feed that in, and that's going to generate a warning. Now if we expand on the warning it talks something about non-referencing pointers, and it's not exactly clear what the problem is. Anyway, if we expand this and compare these two lists, I can show you what the issue is.
As you scroll through these lists here, when I get to item number 18 and 21, and there they are here, 18 and 21, those are coming up null. That's really what the problem is is sometimes when you feed null values into these nodes it causes an error. Depending on what you're going to do with the information coming out of these nodes, it may or may not be an issue. Sometimes the node downstream is capable of just ignoring the null values and processing anyway.
Sometimes it's not. In this case what we're going to want to do is strip out those null values so that we can proceed. And that will be the subject of the next video.
- Placing a single Revit Family
- Selecting elements with basic selection nodes
- Lists and lacing
- Renaming multiple project views
- Adaptive component requirements
- Selecting elements by family type
- Joining multiple lists into a single list
- Removing the unwanted points
- Reorganizing points