Skip to content

magnetic_box.scad

pinkfish edited this page Jun 19, 2025 · 10 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
width outside width of the box
length inside width 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)
material_colour the colour of the material in the box (default default_material_colour)

Example 1:

MakeBoxWithMagneticLid Example 1
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(width = 100, length = 50, height = 20, magnet_diameter = 5, magnet_thickness = 1);

Module: MakeBoxWithMagneticLidInsideSpace()

Topics: MagneticLid

Usage: MakeBoxWithMagneticLidInsideSpace(100, 20, 20, 4, 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
width outside width of the box
length inside width 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(width = 100, length = 50, height = 20, magnet_diameter = 5, magnet_thickness =
1);

Example 2:

MakeBoxWithMagneticLidInsideSpace() Example 2
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(width = 100, length = 50, height = 20, magnet_diameter = 5, magnet_thickness = 1)
  MakeBoxWithMagneticLidInsideSpace(width = 100, length = 50, height = 20, magnet_diameter = 5, magnet_thickness =
  1);

Example 3:

MakeBoxWithMagneticLidInsideSpace() Example 3
include <boardgame_toolkit.scad>
MakeBoxWithMagneticLid(width = 100, length = 50, height = 20, magnet_diameter = 5, magnet_thickness = 1)
  MakeBoxWithMagneticLidInsideSpace(width = 100, length = 50, height = 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
width outside width of the box
length inside width of the box
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)
size_sizeing amount of wiggle room between pieces (default m_piece_wiggle_room)
top_thickness the thickness of the all above the catch (default 2)
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
width outside width of the box
length outside length of the box
lid_boundary boundary around the outside for the lid (default 10)
lid_thickness thickness of the lid (default default_lid_thickness)
size_sizeing amount of wiggle room between pieces (default m_piece_wiggle_room)
text_str the string to use for the label
text_length the length of the text to use (defaults to 3/4 of length/width)
text_scale the scale of the text, making it higher or shorter on the width (default 1.0)
label_radius radius of the label corners (default text_width/4)
label_type the type of the label (default default_label_type)
label_border border of the item (default 2)
label_offset offset in from the edge for the label (default 4)
layout_width the width of the layout pieces (default default_lid_layout_width)
shape_width width of the shape (default default_lid_shape_width)
shape_thickness how wide the pieces are (default default_lid_shape_thickness)
aspect_ratio the aspect ratio (multiple by dy) (default default_lid_aspect_ratio)
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)
lid_pattern_dense if the layout is dense (default false)
lid_dense_shape_edges the number of edges on the dense layout (default 6)
material_colour the colour of the material in the box (default default_material_colour)
label_background_colour the colour of the label background (default default_label_background_colour)
finger_hole_size size of the finger hole to use in the lid (default 10)

Example 1:

MagneticBoxLidWithLabelAndCustomShape() Example 1
include <boardgame_toolkit.scad>
MagneticBoxLidWithLabelAndCustomShape(100, 50, 5, 1, text_str = "Frog") {
  ShapeByType(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: SlidingCatch

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

Description:

Lid for a sliding catch with a label on top of it.

Arguments:

By Position What it does
width outside width of the box
length inside width of the box
lid_boundary boundary around the outside for the lid (default 10)
lid_thickness thickness of the lid (default default_lid_thickness)
top_thickness thickness of the top above the lid (default 1)
size_sizeing amount of wiggle room between pieces (default m_piece_wiggle_room)
lid_wall_thickness the thickess of the walls in the lid (default wall_thickness / 2)
finger_hold_height how heigh the finger hold bit it is (default 5)
text_str the string to use for the label
text_length the length of the text to use (defaults to 3/4 of length/width)
text_scale the scale of the text, making it higher or shorter on the width (default 1.0)
label_radius radius of the label corners (default text_width/4)
label_type the type of the label (default default_label_type)
label_border border of the item (default 2)
label_offset offset in from the edge for the label (default 4)
layout_width the width of the layout pieces (default default_lid_layout_width)
shape_width width of the shape (default default_lid_shape_width)
shape_thickness how wide the pieces are (default default_lid_shape_thickness)
aspect_ratio the aspect ratio (multiple by dy) (default default_lid_aspect_ratio)
size_spacing extra spacing to apply between pieces (default m_piece_wiggle_room)
material_colour the colour of the material in the box (default default_material_colour)
label_background_colour the colour of the label background (default default_label_background_colour)

Example 1:

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




Clone this wiki locally