C3. Orient bricks for 3D printing

Translate each voussoir to the origin

a_Translatre brick to assembly bed

#####################################################################
#Assembly bed frames 
#####################################################################
to_frames = []
num_x = int(round(math.sqrt((len(blocks)))))
num_y = int(round(math.sqrt((len(blocks)))))
spacing = 3
for i in range(num_x):
    for j in range(num_y):
        point = Point(i*spacing,j*spacing,0)
        x_axis = Vector.Xaxis()
        y_axis = Vector.Yaxis()
        to_frames.append(Frame(point,x_axis,y_axis))

if len(to_frames) == len(blocks):
    pass
elif len(to_frames) != len(blocks):
    n = len(to_frames) - len(blocks)
    new_to_frames= to_frames[:(len(to_frames) - n)]
    
artist = FrameArtist(None, "Fabrication::to_frames")
artist.clear_layer()

for frame in to_frames:
    artist = FrameArtist(frame , "Fabrication::to_frames")

artist.redraw()
#####################################################################
#Translate blocks to frame 
#####################################################################
for frame, block in zip (to_frames, blocks):
    point = block.face_centroid(1)
    normal = block.face_normal(1)
    vertices = block.face_vertices(1)
    xaxis = subtract_vectors(block.vertex_attributes(vertices[0], 'xyz'), point)
    yaxis = cross_vectors(xaxis, normal)
    local = Frame(point, xaxis, yaxis)
    X = Transformation.from_frame_to_frame(local, frame)
    block.transform(X)

#####################################################################
#Visualize
#####################################################################
artist = MeshArtist(None, layer="RV2::BlocksTransformed")
artist.clear_layer()

for block in blocks:
    artist.mesh = block
    artist.draw_faces(color=(0, 255, 0), join_faces=True)

artist.redraw()

Last updated