Revit + Dynamo - Drains in curved retaining wall - example 18
Will continue to build on the retaining wall, made in example 6,7 and 8. Here drains will be added, a total of 29, as shown in picture 2. Many of the techniques used are been done in previous examples. The pickle here will be to rotate the 29 drains in XY-plane and 2 rotations around the Z-axis, and every 29 drains will have individual rotation values.
Pick edge, The curve selected will place the drains at a fixed distance between eachother along the curve.
Code block. The number 0.0165 and 0.95 just means that the first point(of the total of 29 points at the curve) starts 1,65% from the start at the curve, and the last point ends 5% from the end of the curve.
Length, width, and height determine the geometry of the drain.
The last one determines the slope.
2. Rotate geometry 90 degrees on the curve
This one we have used a couple of times in previous examples. Want to rotate the geometry in the XY-plane, so that it has a 90-degree angle to the curve. So on every point along the curve the geometry placed has this angle. As you can see from picture 4, every angle is different. This is done by creating a line.ByTangency, this line forms a vector, then find the angle between the Line vector and the vector for the XAxis. Rotate it 90 degrees and flatten the list with List.Flatten so it is compatible with the Geometry.Rotate node.
3. Rotate geometry in the Z-axis
Here comes the pickle! I want to give the geometry(drains) placed at each point a slight tilt along the curve so each drain follows the z variation to the curve. This means that the tilt cant be a fixed value but an individual one dependent on the slope of the curve at the specific point.
We do this by finding the angle between the ZAxis vector and the previously found vector for the Line tangent to the curve( this vector contain a Z vector variation), rotate the found angle 90 degrees and end up with a angle that represents that little tilt at each point along the curve.
4.90 degrees vector on the curve
The last pickle can also be solved to rotate the vector found in section 2. We do this by rotating the vector that is a tangent vector for the curve 90 degrees, so when we rotate the geometry later, it will rotate around the vector, and the angle is gonna rotate is the angle found in section 3.
I have added picture 6, it is another path to find the described vector above.
Here we place the geometry and actually use all the angles and vectors made in sections 2-4.
A total of 3 rotations are necessary to place the drains as desired. Each one will have individual rotation, this is where dynamo really shines.
First Geometry.Rotate is used to rotate the geometry 90 degrees on the curve in XY-plane.
In the second one, we use one of the input values, the slope at the geometry, that is 90 degrees on the curve, we rotate it around the vector that is based on the line. tangent of the curve.
The last Geometry.Rotate, we tilt the drain along the curve, using what we created in section 3 and 4.
Geometry.Translate will deploy the drain geometry at the coordinates found along the curve, with the specific rotations.
Import the created geometry into Revit, Boolean is set to true, since this will be a void.