Happy Friday! For me, this marks the end of week 7 of quarantine here in the Bay Area. We’ve been trying to keep ourselves busy. One of the things my husband and I started doing is having Skype game nights with friends. We found some board games that work pretty well and we also purchased some computer games that are good for groups. I hope you are all staying healthy and sane.
As you know, I am tackling placing exterior elevations based on selected walls. Last week, we found the normal of curved walls so we could properly locate our elevation marker. This week we are going to offset our elevation marker so it correctly aligns with the curved wall.
I would like to add one note about a challenge that I found with the wall's normal. When I was testing this plug-in I had always created new curved walls to try it and had placed them where I wanted to test them. It wasn’t until I accidentally copied and pasted walls and then rotated them when I realized an interesting feature. The endpoints of a wall’s LocationCurve stay the same when you rotate walls. But the x and y direction parameter changes. This means that the walls are first created in the model coordinate space but when you rotate them they will be in a transformed space. The methods we used to find the wall's normal won't work if a curved wall was rotated after it was placed. I believe that this will apply to a small number of cases so I won’t be addressing it in this series. I did want to point it out so you are aware and can adjust your code to accommodate. I do have it on my list to address in the future.
Part 1: elevation by wall
Part 2: phases
Part 3: rotating elevation markers
We will be adding a GetElevationMarkerPosition method which we
will call within out PlaceMarker method that we wrote in Part 1.
This will find the offset center for both curved walls and straight walls. Within our method, we
add an if statement to separate our curved walls. We can do the same test for our
if statement that we have done in the past. We try to cast the wall’s LocationCurve
as an Arc and if that works then we know our wall is curved. After the last post
Part 5, I have pullout out the code for finding the normal of a wall into its own method. This way we can use it again. I called it NormalofCurvedWall and output not only the angle of the normal, I also output a boolean parameter so we know if the wall is concave or convex.
Within our if statement, we declare a few of our variables, call the NormalofCurvedWall method, and get the endpoints for our curve. This then allows us to get the angle that the curved wall’s orientation is at. This is the angle of the line that connects the two endpoints of the wall’s location curve. When we find the normal angle of the wall, that angle is relative to the model’s coordinate space, however, we need to find the angle between the wall’s normal and the wall’s orientation. So we update the wNormalAngle to be the wNormalAngle minus the angleLine EP1EP2. We add a negative because the axis of rotation for the marker is inverted.
Adjusting the normal is necessary for all curved walls. If a wall is concave, we want the wall center to be in between the two endpoints of the curve. That way, we can offset the marker’s location from this center by 5 feet and it will have the same offset as our straight walls. Our wall's normal is in radians and we need to find the vector for that angle so we can offset our elevation marker in the correct direction. To do that, we can use a rotation matrix and rotate our wall’s Orientation, which is the vector between the wall’s endpoints, and rotate it by the angle of our wall’s normal to get the wall’s normal as a vector. We also need to find the center which, for concave walls, we want to have as the center between the two endpoints.
If a wall is convex, we still want to find the wall’s normal as a vector just as we did for concave walls. However, we need to use the negative of the wall’s normal as an angle. This is because a rotation matrix rotates the coordinate counter-clockwise when it is rotated about the Z-axis, but when rotating elevation markers around the Z-axis, it rotates clockwise. To accommodate for that, we use the negative of the angle. Our wall center for convex walls will be the center, plus the offset of the radius, times the wall’s normal. This will place it at the center of the rounded part of the curve, or the peak.
This covers when our wall is curved, we also need our else statement for finding the center and the normal for a straight line.
And finally, regardless of what type of wall it is, we can offset the center by 5 feet in the direction of the normal of the wall. This offset makes sure that the marker does not overlap with the wall. Since it is the same offset for curved and straight walls, we can do this at the end of our method and then return this offset center so we can use it in our PlaceElevations method.
And that wraps up the adjustments we have to make to correctly place the marker for curved walls. The last item we want to update is adding the user selection for the walls so you can select the walls through Revit by clicking on them.
For reference, the NormalofCurveWall method. We put together the steps in Part 5, but I pulled it out into a separate method so we can use it again.