Revit dynamo - Model handrails- example 10

0. Intro

In this example, we build on example 9, by modeling a total of 3 handrails for our railing, shown in picture 2, on the previously modeled posts.  

1. Input

First, we use Select face to select the same surface that our posts have been placed on. We then decide two distances, the height, and distance from the curve centered on the center of the selected surface. 

The last two inputs are radius and thickness for the handrail. 

Picture 1
Picture 2

2. Curve on surface, center.

We take the surface selected in 1 and find the curve placed at the center of the surface, with the node Curve.ByIsoCurvesOnSurface. the input values decide direction and placement, with the value 0,5, the curve is placed at the center of the surface. 

Picture 3

3. Distance x, 90 degrees on the curve

The next section has been done a couple of times in earlier examples.  

We want to create individual vectors that are perpendicular to the line for every 100 points we set along the line, this allows us to get the correct distance from center on each in the 100 points. 

The first step is to make a plane perpendicular to the line for each of the 100 points, using Curve.PlaneAtParamter. further, turn this into a vector with Plane.Normal, Then extracting the vector from Plane.Normal, we only need direction in XY-plane, then rotate the vector 90 degrees. For some reason, the z-values are not 0, so I have to do one last step. Retrieves vector.X and vector.Y from the previous Vector.Rotate, and uses Vector.ByCoordinates to merge the vectors again, leaving the Z vector blank, The reason why is because we want this value to be 0(only rotation in XY-plane). We now have 100 individual vectors in XY direction for each of the points along the line.

The next step in this section is to use the newly created vectors to create a line, with the node Line.ByPointDirectionLength, the distance is fixed and retrieved from 1. input: distance from the center.

The last step is to obtain the endpoint on all the lines with the node Curve.EndPoint. 

Picture 4

4. Points along a path.

Continuous with the points found at the end of section 3 by translating them in the Z-direction(Geometry.Translate), with the input value height on railing.

The newly created points are used to create a curve with node NurbsCurve.ByCoordinates, The curve created, will act as the center of the handrail 2 and path for the sweep done in section 6.Thickness railing. 

Picture 5

5. Circles placed at the curve 

The mission here is applying the two circles(Circle.ByPointRadius), with the radius and one with the radius minus the thickness, determined in the input section to the newly created curve. Both circles are moved and rotated (Geometry.Rotate – CoordinateSystem.ByPlane, CoordinatesSystem.Yaxis) to the endpoint on the created curve where the handrail should be.

Picture 6

6. Thickness railing

Solid.BySweep is used to create two solid tubes, one with the full radius used and the other with the full radius minus the thickness. Further, Geometry.Split(Same technique was used in example 2) is used to split the larger solid tube with the smaller one. We now have two solids. The one we want is the bigger hollow tube, with the correct radius and thickness, Obtain that with List.GetItemAtIndex, This is the geometry that will be imported to Revit. 

Picture 7

7. Import to Revit

Here we have taken the liberty to use a custom node ꟿ FamilyInstance.ByGeometry, Found in the package spring nodes, created by Dimitar.ven. the node import geometry to Revit.

Picture 7

8. Conclusion

Picture 8
Picture 9