## Revit dynamo - Model railing posts - example 9

0. Intro

In this example, we want to place a family with a specific rotation in the XY-plane, along a selected surface, with a fixed distance between the families. In this case, the families will be a post (Se picture 2), but the method will be applicable to all families.

1. Input

First, we use Select face to select the surface we want to place the families at(picture 3). Further, we decide the distance between the post, in this matter, 2 meters, and the distance from the edge of the surface where the post is going to end. The last option is to select a family type. (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.

3. Calculate the number of posts

Here we calculate the number of points(number of posts), and percentage distance between the posts, along the curve we need based on the input values decided in 1.  In this example, we get 4 points.

Code block used, determines the distance between each point along the curve in percentage(b-value) and how many points it should be(a-value).

4. Rotate post in XY-plane, 90 degrees on the curve

If no rotation is set, the families will line up with Revit’s internal coordinates system. Therefore, we need to extract the rotation on each post along the curve.

We do that by creating 2 vectors and measure the angle between them. The first thing we do is to use Line.ByTangency, this is the line, tangent to the curve along the selected surface on each of the 4 points calculated in the previous section. We then find the angle, using Vector.AngleAboutAxis, between the tangent vector and the default x-vector in the XY-plane –> around Z-axis.

In our example, we want to rotate the family 90 degrees on the curve, so we add 90 degrees on the previously found angle using Formula.

It’s important to find this angle, cause the angle for each point is different.

5. Points along the curve.

Code block used in 3. Calculate the number of posts, is the input param in the node Curve.PointAtParameter(The lacing on this node must be set to longest). The node divides the curve into points, which is used to place the families.