For my next series, I wanted to explore the Revit API a bit further and dive into Curtain Walls. I’ve found that a common Dynamo script is a script that randomizes curtain wall mullions. Its mentioned across many forum posts and resources. I wanted to make sure to say thanks to my colleague Payam Rad (who also posts helpful Revit tips and tricks you can check out) who requested this script and gave us the idea to put it together for our firm a few years ago. Panelized rain screens are still a trendy design feature and having a script to randomize these panels saves time. Since it is still in use, I wanted to explore the topic in more detail and also look at customization options that can more easily be incorporated through the Revit API. I think the biggest benefit to using a plug-in is the additional control a user has when presented with a well planned user interface.
I would say that this plug-in is all about options. The goal is to create the most flexibility. A lot of this flexibility is accomplished through the user interface but it is also accomplished in how we write our methods. One of the options I wanted to incorporate was the option to create the CurtainGrid. This way you could even use the tool just to create a CurtainGrid. I incorporated a selection in the dialog box (more on this later) that allows the user to select if they would like to use the grid they already created or if they would like the plug-in to create this grid based on width and height information. I allowed this to be a user selected option because I understand you may also just want to randomly delete CurtainGrid Lines and use your own grid.
So the first overarching goal is to create a CurtainGrid for the CurtainWall using width and height information. There are a few steps we need to take to get there. One item to consider is what the input will be. In this case, the user will select a curtain wall in Revit. We need to assume they forgot to delete the grid. So if we are creating a grid, the first thing we actually need to do is delete the existing grid lines. This is what we will walk through today.
We can start our first public method and call it DeleteAllGrids. We will not return anything. In Revit, CurtainWalls have CurtainGrids and these grids are separated into the U (horizontal) and V (vertical) grids lines. We can use the GetUGridLineIds and GetVGridLineIds methods to collect these elements. Revit also has a handy Delete method we can use. It looks like we just solved the problem in four lines of code, however this is not the case. It’s not that simple when it comes to CurtainWalls.
In Revit, you can create CurtainWall Types that automatically create CurtainGrids when a user places that Type of CurtainWall. If a CurtainGrid is created through this way, it has a Revit parameter called Type Association which is set to “dependent”. If a CurtainGrid is dependent, you cannot delete it. When you manually set this Revit parameter to be “independent” through Revit, the parameter is hidden.
I was playing around a bit with Revit LookUp and logging some additional information and found out that the Type Association is stored as an integer. When the CurtainGrid is “dependent”, the Type Association is 1 and if it is “independent” it is 0. So we want get the Type Association parameter using the GetParameters method. If the Type Association is equal to 1 (dependent) then we want to make sure we set it to 0 (independent).
Then we also have to keep in mind that a user can lock elements in Revit. This includes CurtainGrids, and you cannot delete locked elements. This is a very simple check. For each grid, we just want to check if the Lock property is true and if it is, set it to false.
Finally, once we’ve done all the checks to make sure it is possible to delete the grid, then we can delete it. We can repeat the same for the vertical grids.
And that wraps up the considerations for deleting curtain grids. Next week, we will start to process of creating a new CurtainGrid and discuss some of the challenges with finding the coordinates to use.