---
title: "Giving a Turtle Magnetic Attraction"
date: 2026-11-30T12:00:00Z
url: https://blog.lmorchard.com/2026/11/30/turtle-sandbox-magnets/
author: "Les Orchard"
tags: ["3dprinting", "cad", "magnets", "hardware", "python", "projects"]
---

# Giving a Turtle Magnetic Attraction

TL;DR: Remixed a classic green turtle sandbox 3D print into a magnetic needle keeper. Fitting 38 neodymium magnets mid-print meant thickening the floor with Python computational geometry, testing pull clearances, and surviving a pause-and-insert dance without wrecking the hotend.

<!--more-->

<nav role="navigation" class="table-of-contents"></nav>

## The goal

So, I wanted to make a little plastic turtle sandbox that could hold sewing needles and miscellaneous metal bits.

The starting point was this little "[Retro Turtle Sandbox](https://www.printables.com/model/427130-retro-turtle-sandbox-or-keepsake-stash-box)" by [Grandpa 3DPrints](https://www.printables.com/@Grandpa3DPrints)—modeled after those classic green plastic turtle sandboxes every kid in the 1980s had in their backyard. I wanted to remix this model to embed an array of neodymium magnets, so needles, pins, and paperclips snap securely to the shell floor. 

This became a dive into computational geometry and nozzle brinkmanship, about which I knew next to nothing before I began.

## Fitting coupons

I've never played with embedding magnets in a 3D print. So, before committing to a long design process on the whole turtle, I printed several small "[fitting coupons](https://kapycad.com/en/academy/3dprint/test-coupons)" with varying cavity sizes and model thicknesses. 

I've been using [`build123d`](https://github.com/gumyr/build123d) lately for code-CAD projects, which was fantastic for whipping up parametric test swatches: a few lines of Python to extrude a rounded square and pocket out cylindrical voids.

And, while this isn't the exact code I used to build these models, here's roughly what it looks like with `build123d`, simplified for reading pleasure:

```python
from build123d import *

# Parametric magnet test coupon
coupon_w, coupon_h = 38.0, 3.4
corner_r = 3.0
pocket_d = 10.2     # Bore clearance for 10.0mm nominal magnet
pocket_depth = 2.2 # Room for double-stacked 10x1mm magnets + tolerance

with BuildPart() as coupon:
    # 1. Base rounded swatch
    with BuildSketch():
        RectangleRounded(coupon_w, coupon_w, corner_r)
    extrude(amount=coupon_h)
    
    # 2. Bore cylindrical pockets into the top face
    with BuildSketch(coupon.faces().sort_by(Axis.Z)[-1]):
        with Locations((0.0, 6.495), (-7.5, -6.495), (7.5, -6.495)):
            Circle(radius=pocket_d / 2)
    extrude(amount=-pocket_depth, mode=Mode.SUBTRACT)

export_stl(coupon.part, "coupon_cluster.stl")
```

<figure>
  <stl-viewer src="coupon_cluster_build123d.stl" title="Parametric Test Coupon" height="340px" style="max-width: 480px; margin: 0 auto;"></stl-viewer>
  <figcaption>The 3D model generated directly by the build123d script above.</figcaption>
</figure>

That let me test two things: how thin the covering ceiling could be while still bridging cleanly, and how well the magnets actually grabbed pins through that skin. A single 10×1mm disc under a 0.6mm (3-layer) ceiling felt anemic—needles would slide around lazily. But double-stacking two magnets in each hole (a 2.0mm stack in a 2.2mm cavity) gave a satisfying grab.

A quick stepped tolerance ladder helped nail down the bore diameter: 10.2mm was the sweet spot for a smooth drop-in fit with zero friction against 10.0mm nominal neodymium discs.

<figure class="image-figure wide">
<img src="8b00ca10f2f6.jpg" alt="Four teal 3D-printed square test coupons stuck magnetically to white painted ductwork in a basement">
<figcaption>Basement ductwork torture test: the top two coupons are thicker and hold double-stacked magnets; the bottom two hold single discs. The double-stacked magnets grab much harder.</figcaption>
</figure>

## Geometry exam

The original STL had no space for magnets at all—just a solid 1.6mm tray floor and empty structural voids in the corner feet.

If you want to embed magnets mid-print, you need solid bottom skin below, a clean bore for the cavity, and a solid bridging ceiling above it so the extruded filament can span the void without drooping onto bare metal.

As-is, there wasn't enough vertical room in the model for the sandwich: I needed at least 0.6mm of solid bottom skin, 1.0–2.0mm for the magnet cavity, and at least 0.8mm of ceiling above. That meant at least 2.4mm to 3.4mm of total floor height. 

To gain that, there were really only two options: extend the base down, or raise the floor up.

Extending the base down was the easy trick, but it was a dead end physically. Pushing the bottom down puts extra plastic between the magnets and the inside of the tray. Through that much solid plastic and distance—inverse square law, and all that—the magnets barely had enough pull to hold a sewing needle, let alone snap one into place.

So I had to extend the floor up into the interior cavity. That kept the magnets right beneath the tray surface where needles land, but it meant colliding with the real geometry: the bowl curves upward into the shell, and there are two alignment pillars for the lid. If a pocket clipped into a pillar, the magnet would end up buried under 12–18mm of plastic pulling nothing.

## Rings in Python

While `build123d` was fantastic for modeling the coupons from scratch, the turtle base was a whole different beast: someone else's exported STL mesh. 

Traditional boundary-representation (B-Rep) kernels notoriously choke on raw triangle soup, and trying to do clean CSG booleans on faceted polygons usually ends in tears. So instead of fighting CAD kernels, I treated the mesh as a computational geometry problem in Python using [`trimesh`](https://trimesh.org/), [`NumPy`](https://numpy.org/), and [`Shapely`](https://shapely.readthedocs.io/) to thicken the floor and bore out legal magnet pockets automatically.

Haha 😂 did I sound like I knew what I was talking about, just then? Because I absolutely did not—and still mostly don't. I assure you this was a shit-ton of reading and trial & error to do something that I thought would be simple. 

But I'll save you all that and jump straight to what actually worked:

First, I used `trimesh` to fire a vertical grid of raycasts through the model, measuring the distance between the bottom of the turtle and the inner tray floor. Then a 2D Euclidean distance transform mapped out the legal territory—flagging anywhere the floor was thin enough to be useful while steering clear of the shell curves and lid pillars:

```python
# Fire a dense grid of vertical rays through the STL to map floor thickness
origins = np.column_stack([grid_xy, np.full(len(grid_xy), -9.0)])
loc, ray_idx, _ = mesh.ray.intersects_location(origins, [0.0, 0.0, 1.0])

# Map out thin-floor regions and compute clearance to walls & pillars
dist_map = scipy.ndimage.distance_transform_edt(thin_floor_mask, sampling=(0.4, 0.4))
```

I started out trying several variations on planar hexagonal grids across the footprint. But because the turtle's tray is roughly circular while the outer shell is an organic shape flanked by those corner pillars, standard grid tiling looked haphazard and collided with the lid alignment posts:

<figure class="image-figure">
<img src="haphazard-hex-grid.png" alt="Python geometry plots showing various candidate hexagonal grid patterns inside the turtle perimeter looking haphazard and colliding with walls and pillars">
<figcaption>Early grid experiments: planar hex grids produced asymmetrical, haphazard pocket patterns that collided with the corner alignment pillars.</figcaption>
</figure>

Realizing the tray floor is roughly circular, I switched from a flat grid to concentric hexagonal rings: one magnet dead center, and nested 6-fold orbits stepping outward at a 15mm pitch:

```python
def rot60(q, r):
    """60° rotation in axial hexagonal coordinates."""
    return (-r, q + r)

def to_xy(q, r, pitch=15.0):
    """Convert axial lattice coords to physical millimeters."""
    return (pitch * (q + r / 2.0), pitch * (r * np.sqrt(3) / 2.0))
```

Every candidate pocket was tested against the distance map. If a pocket’s entire 10.2mm diameter had enough clearance to avoid burrowing into a pillar or breaking through the wall, it was kept. 

That yielded nineteen cavities with clean 6-fold symmetry, taking two stacked magnets each—thirty-eight magnets in all.

This may or may not have been a good idea, since writing all this crap probably took about the same amount of time it would have taken me to just get better at [FreeCAD](https://www.freecad.org/). 😅

But, it worked, and now I think I have tooling I can try reusing the next time something like this pops into my head.

<figure class="wide">
  <stl-viewer src="turtle_magnet_base_v2.1.stl" title="Turtle Sandbox Magnet Base (v2.1)" color="#2ec4b6" height="420px" style="margin: 0;"></stl-viewer>
  <figcaption>Interactive 3D preview: modified turtle base with nineteen concentric magnet cavities. Scrub the Z-slider to layer 19 (Z=3.8mm) to view the open magnet pockets before bridging.</figcaption>
</figure>

## Pause and insert

Printing is the fun part. 

You slice the model with an unconditional pause command (`M601`) right at the layer before the pocket ceilings start bridging (Z=3.8mm). When the print head parks itself off to the side, you have a couple of minutes to drop thirty-eight greasy little rare-earth magnets into their nineteen snug holes. 

<figure class="image-figure">
<img src="859dcfe8ab99.jpg" alt="A teal 3D printed turtle base on a textured gray build plate with circular metal magnets inserted into pockets"><figcaption>Mid-print pause: dropping thirty-eight magnets into nineteen pockets before the roof goes on.</figcaption>
</figure>

The annoying part is polarity—if two adjacent magnets flip and jump out of their pockets to stick together. Also, it's likely they'll latch onto the steel heat block when the print resumes and maybe wreck the extruder.

Luckily, my wife treated me to a diamond nozzle a few years back, which made the hotend far less attractive to magnets and let the print run smooth.

<image-gallery>

![Two teal 3D-printed plastic pieces on a wooden table: a round lid and a turtle-shaped trinket box with embedded magnets](2261cd1df55b.jpg)

![A completed teal 3D-printed turtle trinket box with a textured shell, feet, and head sitting on a wooden desk](1219626d2a89.jpg)

</image-gallery>

Fortunately, [the magnets stayed in their homes](https://masto.hackers.town/@lmorchard/117712017717577391), the printer bridged over them without a hitch, and now we have a sandbox turtle with genuine magnetic superpowers. 

At some point, I might get around to uploading my remix to Printables. Then, if you want a magnetic turtle, you can just do the part where you risk flinging magnets around inside your 3D printer.

