The Startup
Published in

The Startup

Designing 3D Printed Board Game Inserts with Python

My finished insert for Burgle Bros
Setup game of Burgle Bros

3D Printing Primer

Generating STL Files with Python

Making Our First Box

# box.py
import solid
# Size for our box
length, width, height = 100, 150, 50
# Wall thickness
wall = 3
box = solid.cube(size=[length, width, height])
# Inner box needs to be smaller based on the wall size
inside = solid.cube(
size=[length - 2 * wall, width - 2 * wall, height - wall])
# Offset inner box
inside = solid.translate([wall, wall, wall])(inside)
# Remove inner box from the outer to create the empty space
box += solid.hole()(inside)
solid.scad_render_to_file(box, "box.scad", include_orig_code=False)
# Make sure you have SolidPython installed
$ python -m pip install solidpython
# Run the above script saved as box.py
$ python box.py
# Convert scad to stl
$ openscad -o box.stl box.scad
# box.py (continued)def roundbox(size, radius):
"""Box with rounded edges."""
x, y, z = size
# Adjust the box size to maintain the original dimensions
x = x - radius * 2
y = y - radius * 2
z = z - 1
return solid.minkowski()(
solid.cube(size=[x, y, z]),
solid.cylinder(r=radius),
)

Creating the Burgle Bros Insert

# box.py (continued)wall = 3
# Tokens holder
x, y, z = 171, 60, 15
box = roundbox([x, y, z], radius=2)
# Make 4 equal size wells
wells = 4
size = (x - (wells + 1) * wall) / wells
well = roundbox([size, y - wall * 2, z - wall], radius=2)
for i in range(wells):
box += solid.hole()(solid.translate(
[wall * (i + 1) + size * i, wall, wall])(well))
# Output box to SCAD file
solid.scad_render_to_file(
box, "tokens.scad", include_orig_code=False)
# Character, guards and dice holder
x, y, z = 171, 60, 15
box = roundbox([x, y, z], radius=2)
# Character holder (77 mm)
characters = roundbox([77, y - wall * 2, z - wall], radius=2)
box += solid.hole()(solid.translate([wall, wall, wall])(characters))
# Guard holder (52 mm)
guards = roundbox([52, y - wall * 2, z - wall], radius=2)
box += solid.hole()(solid.translate(
[wall * 2 + 77, wall, wall])(guards))
# Dice holder (30 mm)
dice = roundbox([30, y - wall * 2, z - wall], radius=2)
box += solid.hole()(solid.translate(
[wall * 3 + 77 + 52, wall, wall])(dice))
# Output box to SCAD file
solid.scad_render_to_file(
box, "characters.scad", include_orig_code=False)
# Run the above script saved as box.py
$ python box.py
# Convert scad to stl
$ openscad -o tokens.stl tokens.scad
$ openscad -o characters.stl characters.scad

--

--

Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +768K followers.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Mark Lavin

Python/web developer with too many random hobbies. I work for NVIDIA but my opinions are my own.