Skip to content

components.scad

pinkfish edited this page Jun 10, 2026 · 17 revisions

LibFile: components.scad

This file has all the modules needed to generate varioius inserts for board games. It makes the generation of the inserts simpler by creating a number of useful base modules for making boxes and lids of various types specific to board game inserts. Specifically it makes tabbed lids and sliding lids easily.

To use, add the following lines to the beginning of your file:

include <boardgame_toolkit.scad>

File Contents

  1. Section: Components

  2. Section: Curves

  3. Section: Magnets

Section: Components

Building blocks to make all the rest of the items from. This has all the basic parts of the board game toolkit for making polygons and laying them out.

Module: HexBoxDivisions()

Topics: Recess

Usage:

  • HexBoxDivisions([100, 50, 10], 5);

Description:

Creates a box with divisions inside for hex shaped tiles.

Arguments:

By Position What it does
width width of the box
height height of the box
num_sides number of sides of the polygon (default 6)
divisions number of divisions to make
wall_thickness thickness of the walls (default default_wall_thickness)

Example 1:

HexBoxDivisions() Example 1
include <boardgame_toolkit.scad>
HexBoxDivisions(width=100, num_sides=6, height=10, divisions=2);

Module: RoundedBoxOnLength()

Topics: Recess

Usage:

  • RoundedBoxOnLength([100, 50, 10], 5);

Description:

Creates a rounded box for use in the board game insert with a nice radius on two sides (length side).

Arguments:

By Position What it does
size [width, length, height] of the cube
radius radius of the curve on the edges

Example 1:

RoundedBoxOnLength() Example 1
include <boardgame_toolkit.scad>
RoundedBoxOnLength([30, 20, 10], 7);




Module: RoundedBoxAllSides()

Topics: Recess

Usage:

  • RoundedBoxAllSides([30,20,10],5);

Description:

Creates a rounded box with all the sides rounded.

Arguments:

By Position What it does
size [width, length, height] of the cube
radius radius of the curve on the edges

Example 1:

RoundedBoxAllSides() Example 1
include <boardgame_toolkit.scad>
RoundedBoxAllSides([30,30,10], radius=5);




Module: RoundedBoxGrid()

Topics: Recess, Grid

Usage:

  • RoundedBoxGrid(20,20,10,5, rows=2, cols=1);

Description:

Create a grid of rounded boxes, this is useful for inserting a number of containers inside a insert box.

Arguments:

By Position What it does
size [width, length, height] of the space (total, inside will be divided by this)
radius radius of the curve on the edges
rows number of rows to generate
cols number of cols to generate
spacing number of mm between the spaces (default 2)
all_sides round all the sides (default false)

Example 1:

RoundedBoxGrid() Example 1
include <boardgame_toolkit.scad>
RoundedBoxGrid([30, 20, 10], 7, rows=2, cols=1);




Function: PolygonRadiusFromApothem()

Description:

Find the radius of the polygon from apothem.

Arguments:

By Position What it does
apothem apothem of the shape
shape_edges the number of edges on the shape

Function: PolygonApothemFromRadius()

Description:

Find the apothem of the polygon from radius.

Arguments:

By Position What it does
radius radius of the shape
shape_edges the number of edges on the shape

Module: RegularPolygon()

Topics: Recess

Usage:

  • RegularPolygon(10, 5, 6);

Description:

Creates a regular polygon with specific height/width and number of edges.

Arguments:

By Position What it does
width total width of the piece, this is equivalent to the apothem of a polygon * 2
height how high to create the item
shape_edges number of edges for the polygon
finger_holes finger holes to put on the specific edges, from 0-shapeedges
finger_hole_height height of the finger holes
finger_hole_radius the radius of the finger holes
rounding rounding to apply to the polygon edges (default 0)
radius radius of the object

Example 1:

RegularPolygon() Example 1
include <boardgame_toolkit.scad>
RegularPolygon(10, 5, shape_edges = 6);



Example 2:

RegularPolygon() Example 2
include <boardgame_toolkit.scad>
RegularPolygon(10, 5, shape_edges = 6, finger_holes = [0, 3]);




Module: CircleWithIndents()

Description:

Makes a nice cylinder with finger holes bits at the spexific angles.

Arguments:

By Position What it does
radius radius of the circle
height of the cylinder
d diameter of the cylinder (alternative to radius)
r radius of the cylinder (alternative to radius)
h height of the cylinder (alternative to height)
finger_holes finger holes at the specified degrees.
finger_hole_height how much to move it up from the bottom
finger_hole_radius the radius to use for the finger holes
cyl_fn $fn value for the cylinder
anchor BOSL2 anchor

Example 1:

CircleWithIndents() Example 1
include <boardgame_toolkit.scad>
CylinderWithIndents(15, 10, finger_holes = [30, 210]);




Function: HoleToPosition()

Description:

Where the whole should be based on the position number. Used by the various indent methods below for putting holes in cuboids/things.

Arguments:

By Position What it does
pos position to put the hole in

Module: CuboidWithIndentsBottom()

Description:

Makes a nice cuboid with finger holes bits at the specific sides, this anchors to the bottom. The holes are at: [LEFT + FRONT, RIGHT+BACK, LEFT, RIGHT, FRONT, BACK, ]

Arguments:

By Position What it does
size [x,y,z] size of the cuboid
finger_holes finger holes at the specified places
finger_positions specific BOSL2 positions for finger holes
finger_hole_height how much to move it up from the bottom finger_hole_radius =
the radius to use for the finger holes
rounding rounding to use on the hole edges
chamfer chamfer to use on the hole edges
edges which edges to round/chamfer
anchor BOSL2 anchor
finger_hole_radius radius of the finger hole

Example 1:

CuboidWithIndentsBottom() Example 1
include <boardgame_toolkit.scad>
CuboidWithIndentsBottom([15, 10, 10], finger_holes = [1, 5], finger_hole_radius=3);

Example 2:

CuboidWithIndentsBottom() Example 2
include <boardgame_toolkit.scad>
CuboidWithIndentsBottom([15, 10, 10], finger_holes = [0, 4], finger_hole_radius=3);

Example 3:

CuboidWithIndentsBottom() Example 3
include <boardgame_toolkit.scad>
CuboidWithIndentsBottom([15, 10, 10], finger_holes = [0, 4], rounding=2, finger_hole_radius=3, edges=[FRONT+RIGHT, FRONT+LEFT]);

Example 4:

CuboidWithIndentsBottom() Example 4
include <boardgame_toolkit.scad>
CuboidWithIndentsBottom([15, 10, 10], finger_holes = [0, 4], chamfer=2, finger_hole_radius=3, edges=[FRONT+RIGHT, FRONT+LEFT]);

Module: RegularPolygonGrid()

Topics: Grid

Usage:

  • RegularPolygonGrid(10, 2, 1, 2)

Description:

Lays out the grid with all the polygons as children. The layout handles any shape as children. This uses the exact width of the polygon to layout the underlying grid. This just does all the spacing, the actual generation is done using the children to this module. This is usually used in conjuction with RegularPolygon()

Arguments:

By Position What it does
width total width of the piece, this is equivilant to the apothem of a polygon * 2
rows number of rows to generate
cols number of cols to generate
spacing spacing between shapres
shape_edges number of edges for the polygon (default 6)
aspect_ratio ratio between shape and width, the dy is * this (default 1.0)
inner_control if the layout is controled by the client using $polygon_x and $polygon_y as the layout (defaul false)
space_width width of the space for inner_control 2
space_length length of the space for inner_control 2

Example 1:

RegularPolygonGrid() Example 1
include <boardgame_toolkit.scad>
RegularPolygonGrid(width = 10, rows = 2, cols = 1, spacing = 2)
   RegularPolygon(width = 10, height = 5, shape_edges = 6);

Module: RegularPolygonGridDense()

Topics: Grid

Usage:

  • RegularPolygonGridDense(10, 2, 1)

Description:

Lays out the grid with all the polygons as children in a dense layout, this only works for triangles and hexes. It will do a dense space filling using the spacing as the distance between the polygons. This uses the exact width of the polygon to layout the underlying grid. This just does all the spacing, the actual generation is done using the children to this module. This is usually used in conjuction with RegularPolygon()

Arguments:

By Position What it does
radius this is the radius of the polygon, distance from center to edges
rows number of rows to generate
cols number of cols to generate
shape_edges number of edges for the polygon (default 6)
inner_control if the layout is controlled by the client (default false)

Example 1:

RegularPolygonGridDense() Example 1
include <boardgame_toolkit.scad>
RegularPolygonGridDense(radius = 10, rows = 3, cols = 2)
   RegularPolygon(width = 10, height = 5, shape_edges = 6);




Module: HexGridWithCutouts()

Topics: Recess Grid

Usage:

  • HexGridWithCutouts(rows = 4, cols = 3, height = 10, spacing = 0, push_block_height = 1, tile_width = 29);

Description:

This creates a hex grid with cutouts that can be used to cut out piece of a box to make a nice hex spacing inside the box.

Arguments:

By Position What it does
rows rows of the grid
cols colrs of the grid
height height of the grid
spacing space between the tiles
tile_width width of the tiles
push_block_height height of the pushblock to use (default 0)
wall_thickness thickness of the walls (default 2)
inner_control if the layout is controlled by the client (default false)

Example 1:

HexGridWithCutouts() Example 1
include <boardgame_toolkit.scad>
HexGridWithCutouts(rows = 4, cols = 3, height = 10, spacing = 0, push_block_height = 1, tile_width = 29);

Module: FingerHoleWall()

Topics: FingerHole

Description:

Creater a finger hole cutout with nice rounded edges at the top and a cylinder of the specified radius at the bottom.

Arguments:

By Position What it does
radius radius of the finger hole
height height of the finger hole
depth_of_hole how deep to make the cut through the wall (default 6)
rounding_radius how round to make the top in the wall (default 3)
orient orientation of the hole (default UP)
spin spin of the hole (default 0)
material_colour the material colour to use (default default_material_colour)
rounding_edge how much to round the edge to the wall (default 0)
round_front how much to round the front
round_back how much to round the back

Example 1:

FingerHoleWall() Example 1
include <boardgame_toolkit.scad>
FingerHoleWall(10, 20);



Example 2:

FingerHoleWall() Example 2
include <boardgame_toolkit.scad>
FingerHoleWall(10, 9);




Module: CornerCatch()

Description:

Round over on the cornet for a catch, making it nice and smooth.

Arguments:

By Position What it does
radius radius of the hole
height height of the wall
depth_of_hole how deep to make the cut through the wall (default 6)
rounding_radius how round to make the top in the wall (default 3)
orient orientation of the hole (default UP)
spin spin of the hole (default 0)
material_colour the material colour to use (default default_material_colour)
rounding_edge how much to round the edge to the wall (default 0)
round_front round the front end (default true)
round_bkac round the back edge (default true)

Example 1:

CornerCatch() Example 1
include <boardgame_toolkit.scad>
CornerCatch(radius = 2, height = 5);



Example 2:

CornerCatch() Example 2
include <boardgame_toolkit.scad>
CornerCatch(radius = 2, height = 5, rounding_edge=1);




Module: FingerHoleBase()

Topics: FingerHole

Usage: FingerHoldBase(10, 20);

Description:

Creates a hole in the floor of the box with a rounding over at the top to allow for picking up of cards and other things. Center on the side of the wall and the radius of the main section is the offset to the middle.

Arguments:

By Position What it does
radius radius of the hole
height height of the wall
wall_thickness this is used as an offset to move in from the wall by this amount to cut through it (default
2)
rounding_radius rounding radius at the top of the hole (default 3)
orient orintation of the hole, from BOSL2 (default UP)
spin spin of the hole, from BOSL2 (default 0)

Example 1:

FingerHoleBase() Example 1
include <boardgame_toolkit.scad>
FingerHoleBase(10, 20);



Example 2:

FingerHoleBase() Example 2
include <boardgame_toolkit.scad>
FingerHoleBase(10, 20, rounding_radius = 7);




Section: Curves

Module: HilbertCurve()

Usage: HilbertCurve(3, 100);

Description:

Generates a hilbert curve for uses in board games.

Arguments:

By Position What it does
order depth of recursion to use 3 is a reasonable number
size size to generate the curve, this is a square size
line_thickness how thick to generate the lines in the curve (default = 20)
smoothness how smooth to make all the curves (default 32)

Example 1:

HilbertCurve() Example 1
include <boardgame_toolkit.scad>
HilbertCurve(3, 100);




Section: Magnets

Constant: MAGNET_SLOT_TYPE_NONE

Description:

No magnet slot


Constant: MAGNET_SLOT_TYPE_ROUND

Description:

Round magnet slot


Constant: MAGNET_SLOT_TYPE_RECT

Description:

Rectangular magnet slot


Module: MagnetSlot

Description:

Creates a slot for a magnet of a given size and type. The width will be widened a bit based ohn the slot offsets while the height should be press fit and the length won't change.

Arguments:

By Position What it does
size size of the magnet (width, length, height)
magnet_type type of the magnet
orient orintation of the slot, from BOSL2 (default UP)
spin spin of the slot, from BOSL2 (default 0)
slot_offsets offsets for the slot, how much space to put around the slot for the magnet
height_of_slot height of the slot

Example 1:

MagnetSlot Example 1
include <boardgame_toolkit.scad>
MagnetSlot(size = [10, 10, 2], magnet_type = MAGNET_SLOT_TYPE_ROUND);

Example 2:

MagnetSlot Example 2
include <boardgame_toolkit.scad>
MagnetSlot(size = [10, 10, 2], magnet_type = MAGNET_SLOT_TYPE_RECT);

Clone this wiki locally