D2.2 Splines

Visualize Splines

In the edge pockets, we will insert splines (here steel rebars) that can in turn be attached by hooks to the supporting structure. In order to visualize the splines, we first need to find edges where both vertices are anchored. Then we draw a cylinder with the spline radius.

mesh.update_default_edge_attributes({'is_spline': False})

for u, v in mesh.edges():
    if mesh.vertex_attribute(u, 'is_anchor') and mesh.vertex_attribute(v, 'is_anchor'):
        mesh.edge_attribute((u, v), 'is_spline', True)
    elif mesh.edge_attribute((u, v), 'cable'):
        mesh.edge_attribute((u, v), 'is_spline', True)

for u, v in mesh.edges_where({'is_spline': True}):
    sp, ep = mesh.edge_coordinates(u, v)
    lines.append({
        'start': sp,
        'end': ep,
        'radius': radius,
        'color': (255, 0,0),
        'name': "spline.{}-{}".format(u, v)
    })

Calculate Spline Length and Weight

To order splines, we can calculate the edge length.

# initialize the total length and weight
total_length = 0
total_weight = 0
weight = 7850  # kg/m3
section = 0.008**2 * m.pi

# loop through the edges to calculate edge length and weight
for u, v in mesh_1.edges_where({'is_spline': True}):
    edge_len = mesh_1.edge_length(u, v)
    total_length += edge_len
    total_weight += edge_len * weight * section

for u, v in mesh_2.edges_where({'is_spline': True}):
    edge_len = mesh_2.edge_length(u, v)
    total_length += edge_len
    total_weight += edge_len * weight * section

You will see this result in your Rhino output:

Last updated