This past week, I have taken a lot of time to think. I thought about the
impacts we have on the lives of others. What can we all do to better the
future? I encourage everyone to take a minute and do the same. I went in
circles about posting a topic this week. In such challenging times, when
so many people are hurting, it’s easy to feel like there is nothing we can do
to help. I believe that what I can do is to better myself and educate myself
and help others grow as well. This week, I have donated to the NAACP Legal
Defense and Educational Fund and I pledge to donate every week through the
end of June to a different organization that helps bring about the change we need.
USA Today wrote about 100 Ways You Can Take Action Against Racism Right Now.
Not all of the actions require a monetary commitment, so I encourage you to review the resources they have collected.
For this week’s content, I would like to continue looking at the curtain wall grid. Last week, we deleted all the grid lines, so this week we can create new ones.
First we will want to take a look at the method we are using: AddGridLine. There are three parameters we need. These are a boolean to determine if the grid line is a U (true) or a V (false) grid line, a position for placing the grid line, and lastly a boolean to determine if it is adding the entire line (false) or just one segment of it (true). Determining the boolean values are straight forward, but the position can be a bit tricky.
To determine a position for grid lines, I need a coordinate that is in a corner of the curtain wall. This way, I can then add the width or height of the panels to get to the next curtain grid line until I reach the edge of the wall. My first thought was using the bounding box of the curtain wall. When I printed out the minimum coordinate of the bounding box and the coordinates of some of the curtain wall panels, they were not in the same plane. I started thinking that since all the grids are removed, we have one large curtain wall panel. If I can locate the minimum coordinate of the curtain wall panel, I can use this as the starting point for creating the grids. A curtain wall panel does not have any properties that are minimum and maximum values. However, we know that it is made of CurveLoops, which are just lines, which all have endpoints. So finding the minimum coordinate had two steps: collect all the endpoints and find which endpoint is the minimum coordinate. I should also mention that I am targeting to create the CurtainGrid on a flat curtain walls so there are some assumptions we can make.
I start my method and call it GetCWMinMax. The easiest way to store these coordinates is in a tuple so this is what we will return. The parameter taken in by the method is the curtain wall that the user selects. First we declare the variables we will need: the tuple (which we will return with the min and max coordinates) and a list of all the coordinates.
To get the list of coordinates, we first need to retrieve the CurveLoops that construct the curtain wall panel. Since we know there is only one panel, we can safely use the first CurtainCell and get the first set of CurveLoops that defines it. A CurveLoop contains a list of curves, in this case we know that they are all lines because we are working with a single panel, which in Revit cannot be curved. If we add it to our list as a Line we can get the origin of the line so that we only add each endpoint once. Now we have a list of endpoints and we need to find the minimum endpoint. The method we use to find the min and max coordinates from the list can be used for many different situations. I added it to my Utility file so it is easier to use in the future and I called it GetMinMaxFromList.
The next task is finding the minimum and maximum values in a list of coordinates. The challenge here is that these points can be anywhere within the coordinate system. It’s much easier if all the coordinates are in the positive side of the coordinate system. Therefore, we want to find the smallest X and independently the smallest Y coordinates and shift all coordinates by these amounts. We can put this into a new list called xyzListAdjusted.
Now that all the coordinates are in the positive quadrant, we can use Euclidian distance, √(a² + b²), to find the coordinates closest and furthest from (0,0). Then we check which index these coordinates are located at so we can go back to our original coordinate list and find the corresponding coordinates. We then return these original coordinates as our minimum and maximum.
Now we have the starting coordinate at which we can place our new CurtainGridLines. Next week, we will go over placing those lines along the entire curtain wall.