top of page

3D model 2x4 brick

  • Peter
  • May 26
  • 1 min read

Updated: May 29

In this example, we construct a 3D model of a classic 2x4 brick using simple geometric primitives and boolean operations. By combining basic shapes like cylinders and scaled cubes, we replicate the familiar form of the brick, including its hollow underside and studded top. Once the individual brick is modeled, we use simple transformations to generate a colorful pile, showcasing how modular components can be assembled into more complex structures.

from hellotriangle import shapes

# dimensions
l = 31.8
w = 15.8
t = 1.2
h1 = 9.6
h2 = 1.8
d1 = 3.9
diam1 = 4.8
diam2 = 6.5

# create outer shape
brick = shapes.cube().scale([l, w, h1])
cyl = shapes.cylinder(diam1/2.0, 2.0).translate([d1, d1, h1+h2-2.0])

for i in [0.0, d1, 2*d1, 3*d1]:
    for j in [0.0, d1]:
        brick = brick.boolean(cyl.translate([2*i, 2*j, 0.0]), '+')

# add inner cavity
cube = shapes.cube().scale([l-2*t, w-2*t, h1]).translate([t, t,-1.0])
brick = brick.boolean(cube, '-')

# add internal cylinders
cyl1 = shapes.cylinder(diam2/2.0, h1-0.2).translate([l/4.0, w/2.0, 0.0])
cyl2 = shapes.cylinder(diam1/2.0, h1-0.2).translate([l/4.0, w/2.0, -0.2])
cyl3 = cyl1.boolean(cyl2, '-')

for i in [0.0, 8.0, 16.0]:
    brick = brick.boolean(cyl3.translate([i, 0.0, 0.0]), '+')

# position brick
brick = brick.translate([-l/2.0, 0.0, 0.0])

# create pile of bricks
colors = ['#D62246', '#006992', '#2BB786', 'grey']

for i in range(4):
    color = colors[i]
    brick = brick.rotate_Z(90.0).translate([0.0, 0.0, h1])
    draw(brick, color=color)
3D model of pile of bricks
Figure: Pile of colored bricks (would this be stable?)
3D model of 2x4 brick
Figure: Single 2x4 brick
3D model of 2x4 brick (underside)
Figure: Hollow underside

Subscribe to our newsletter

Join our email list and get updates about HelloTriangle. Unsubscribe anytime.

Thanks for submitting!

© 2024 by HelloTriangle

  • LinkedIn
bottom of page