Skip to content

magnetic_box.scad

pinkfish edited this page Mar 20, 2026 · 13 revisions

LibFile: magnetic_box.scad

This file has all the modules needed to generate a magnetic box.

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

include <boardgame_toolkit.scad>

File Contents

  1. Section: MagneticLid

Section: MagneticLid

Module: MakeBoxWithMagneticLid

Topics: MagneticLid

Description:

Makes a box with holes for the round magnets in the corners. Inside the children of the box you can use the $inner_height , $inner_width, $inner_length = length variables to deal with the box sizes.

Arguments:

By Position What it does
size [width, length, height] outside size of the box
magnet_diameter diameter of the magnet
magnet_thickness thickness of the magnet
lid_thickness thickness of the lid (default default_lid_thickness)
magnet_border how far around the edges of the magnet the space should be (default 1.5)
wall_thickness thickness of the walls (default default_wall_thickness)
floor_thickness thickness of the floor (default default_floor_thickness)
material_colour the colour of the material in the box (default default_material_colour)

Example 1:

MakeBoxWithMagneticLid Example 1
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(size = [100, 50, 20], magnet_diameter = 5, magnet_thickness = 1);

Module: MakeBoxWithMagneticLidInsideSpace()

Topics: MagneticLid

Usage: MakeBoxWithMagneticLidInsideSpace([100, 50, 20], 5, 1);

Description:

Makes the inside space template for the box so that it can used to intersect to pull out the corners for the magnet safely.

Arguments:

By Position What it does
size [width, length, height] outside size of the box
magnet_diameter diameter of the magnet
magnet_thickness thickness of the magnet
lid_thickness thickness of the lid (default default_lid_thickness)
wall_thickness thickness of the walls (default default_wall_thickness)
floor_thickness thickness of the floor (default default_floor_thickness)
full_height if the cyclinder should be the full height of the box (default true)
magnet_border how far around the edges of the magnet the space should be (default 1.5)
material_colour the colour of the material in the box (default default_material_colour)

Example 1:

MakeBoxWithMagneticLidInsideSpace() Example 1
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLidInsideSpace(size = [100, 50, 20], magnet_diameter = 5, magnet_thickness =
1);

Example 2:

MakeBoxWithMagneticLidInsideSpace() Example 2
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(size = [100, 50, 20], magnet_diameter = 5, magnet_thickness = 1)
  MakeBoxWithMagneticLidInsideSpace(size = [100, 50, 20], magnet_diameter = 5, magnet_thickness =
  1);

Example 3:

MakeBoxWithMagneticLidInsideSpace() Example 3
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(size = [100, 50, 20], magnet_diameter = 5, magnet_thickness = 1)
  MakeBoxWithMagneticLidInsideSpace(size = [100, 50, 20], magnet_diameter = 5,
  magnet_thickness = 1, full_height = false);

Module: MagneticBoxLid()

Topics: MagneticLid

Usage: MagneticBoxLid([100, 50], 5, 1);

Arguments:

By Position What it does
size [width, length] of the lid
magnet_diameter diameter of the magnet
magnet_thickness thickness of the magnet
magnet_border how far around the edges of the magnet the space should be (default 1.5)
lid_thickness thickness of the lid (default default_lid_thickness)
wall_thickness thickness of the walls (default default_wall_thickness)
lid_rounding how much rounding on the edge of the lid (default wall_thickness)
size_spacing amount of wiggle room between pieces (default m_piece_wiggle_room)
material_colour the colour of the material in the box (default default_material_colour)

Example 1:

MagneticBoxLid() Example 1
include <boardgame_toolkit.scad>
MagneticBoxLid([100, 50], 5, 1);




Module: MagneticBoxLidWithLabelAndCustomShape()

Topics: MagneticLid

Usage: MagneticBoxLidWithLabelAndCustomShape([100, 50], 5, 1, text\_str = "Frog");

Description:

Lid for a magnetic lid box. This uses the first child as the shape for repeating on the lid.

Arguments:

By Position What it does
size [width, length] of the lid
magnet_diameter diameter of the magnet
magnet_thickness thickness of the magnet
text_str the string to use for the label
lid_boundary boundary around the outside for the lid (default 10)
layout_width the width of the layout pieces (default default_lid_layout_width)
size_spacing extra spacing to apply between pieces (default m_piece_wiggle_room)
lid_thickness thickness of the lid (default default_lid_thickness)
aspect_ratio the aspect ratio (multiple by dy) (default default_lid_aspect_ratio)
lid_rounding how much rounding on the edge of the lid (default wall_thickness/2)
wall_thickness thickness of the walls (default default_wall_thickness)
lid_pattern_dense if the layout is dense (default false)
lid_dense_shape_edges the number of edges on the dense layout (default 6)
pattern_inner_control if the pattern needs inner control (default false)
material_colour the colour of the material in the box (default default_material_colour)
label_options options for the label (default undef)

Example 1:

MagneticBoxLidWithLabelAndCustomShape() Example 1
include <boardgame_toolkit.scad>
MagneticBoxLidWithLabelAndCustomShape([100, 50], 5, 1, text_str = "Frog") {
  ShapeByType(MakeShapeObject(shape_type = SHAPE_TYPE_SUPERSHAPE, shape_thickness = 2, supershape_m1 = 12, supershape_m2 = 12,
     supershape_n1 = 1, supershape_b = 1.5, shape_width = 15));
}

Module: MagneticBoxLidWithLabel()

Topics: MagneticLid

Usage: MagneticBoxLidWithLabel([100, 50], 5, 1, text\_str = "Frog");

Description:

Lid for a magnetic box with a label on top of it.

Arguments:

By Position What it does
size [width, length] of the lid
magnet_diameter diameter of the magnet
magnet_thickness thickness of the magnet
text_str the string to use for the label
magnet_border how far around the edges of the magnet the space should be (default 1.5)
lid_boundary boundary around the outside for the lid (default 10)
layout_width the width of the layout pieces (default default_lid_layout_width)
aspect_ratio the aspect ratio (multiple by dy) (default default_lid_aspect_ratio)
lid_thickness thickness of the lid (default default_lid_thickness)
wall_thickness thickness of the walls (default default_wall_thickness)
size_spacing extra spacing to apply between pieces (default m_piece_wiggle_room)
lid_rounding how much rounding on the edge of the lid (default wall_thickness/2)
material_colour the colour of the material in the box (default default_material_colour)
label_options options for the label (default undef)
shape_options options for the shape (default undef)

Example 1:

MagneticBoxLidWithLabel() Example 1
include <boardgame_toolkit.scad>
MagneticBoxLidWithLabel([100, 50], 5, 1, text_str = "Frog");




Clone this wiki locally