kapy academy

Magnets in mechanisms

18 min readUpdated Nov 2026

You glue two magnets into a test lid and it shuts with a firm snap. You print the real box and the lid barely holds: the real part left 0.6 mm of plastic over each magnet, plus the clearance the pause leaves above it, and that was enough to cut the force to a third or less. A magnetic catch (a lid, a door, a module that clicks into place) or a magnetic detent (a knob that stops at fixed positions) has no arm to fatigue or creep. The price: its force depends on tenths of a millimeter, and it only holds well head-on.

The force falls with the gap, fastest at the start

At a distance much larger than their size, two coaxial magnets attract like two dipoles:

F = 3·μ0·m1·m2 / (2π·r⁴)

Double the distance and the force drops by a factor of 16, not 8. The field falls with the cube of the distance; the force falls with the fourth power.

A printed catch works almost in contact: between 0 and 2 mm, with Ø6–10 mm magnets. In that range the dipole law does not apply. The force is finite at contact and falls fastest right at the start; there is no plateau. As a rough guide, for a Ø6 × 3 disc against steel, on its axis, you keep about 70 % of the contact force at 0.5 mm, 45 % at 1 mm and 20 % at 2 mm. These are estimates from the on-axis field of a cylinder; your own numbers come from the test coupon.

The gap is the total distance between the magnet face and its partner: the wall on side A, plus the air left with the lid closed, plus the wall on side B. Count both halves. The air is set by how the lid fits: if a lip or a locating tab bottoms out first, the magnets never touch and the gap grows without you seeing it. Design the magnet faces to be the last contact, or recess them 0.1 mm on purpose and add that to the stackup (Assemblies and tolerance stackups).

2040608010000.511.522.53Floors on the bed 0.4 + 0.4Roofs after a pauseEstimate, Ø6 × 3 against steelFar field ∝ 1/r⁴Gap (mm)Force (% of contact force)MagnetSteel or magnett1Wall, side AaAirt2Wall, side BGap g = t1 + a + t2g
Pull force against gap, estimated for a Ø6 × 3 disc against steel. The curve falls from contact with no plateau; the dipole law only describes the tail. On the right, the gap is the sum of both walls and the air.

In practice, the first tenths cost the most. Going from N42 to N52 gives you about 23 % more force; a 0.6 mm printed roof takes away more than a third. Thinning the plastic almost always pays off more than a higher grade or a bigger magnet.

The catalog pull force is measured by pulling straight off a thick steel plate. Magnet against magnet, or magnet against a thin washer, gives different figures. For a specific pair and gap, use the supplier's calculator (supermagnete and K&J Magnetics both publish one) or the coupon at the end of this page. Do not extrapolate from the catalog figure alone.

Head-on it holds; sideways it only rubs

Pull force is axial. Sideways, the magnet holds only through friction between the faces: F_side = μ·P, with P the force pressing the faces together. According to the supplier, a bare Ø6 × 2 N45 disc on steel (supermagnete S-06-02-N) gives 7.26 N (740 g) of pull and 1.46 N (150 g) of shear: roughly one fifth. Each supplier quotes its own figures for the same size (ALB lists 0.80 kg of pull): treat them as an example, not a standard. That one fifth applies to a nickel-plated magnet on steel; if two printed plastic faces are rubbing, μ rises to 0.3–0.5, but it is still an unreliable grip.

Hence the rule: the magnet closes the lid and keeps it down; side loads go into a lip, a tab or two locating pins. A lid that slides off when knocked does not have a weak magnet: it is missing a lip. When the side load is the whole problem, such as a weight hanging from a vertical face, see Phone mounts.

Self-centering exists, but it is weak. When the pair is offset, a sideways pull toward alignment appears, but it is small, of the same order as the friction it has to overcome. Treat it as help for the lid to find its place. Locating to a tenth is the geometry's job: a lip, a cone, a pair of pins.

Magnet to magnet, or magnet to steel?

With magnet to magnet, both sides contribute field, the centering is firmer and polarity matters: a pair fitted the wrong way round repels.

With magnet to steel (a disc, a sheet, a screw head) there is no polarity: the lid closes in any orientation, and steel is cheaper. Thin steel saturates, and a disc the same diameter as the magnet misses the flux that returns outside its edge: both pull noticeably less than the catalog's thick plate, so measure it. A washer loses even more, because it has no center. Watch out for stainless: A2 and A4 screws and washers are austenitic, barely magnetic, and useless as a partner; use zinc-plated steel. The wall covering the steel also adds to the gap.

Polarity works as a key only with magnet to magnet. With two or more pairs, alternate N and S in the lid: it closes in one orientation only, and turned 180° it repels and will not seat. All the same polarity: it closes both ways. Decide it on purpose.

Mind the neighbors: keep steel screws, inserts and other magnets several magnet diameters away from a catch or a detent. They divert the field and shift the rest position.

Seating the magnet: a floor on the bed or a roof after a pause

Design the pocket at Ø + 0.3 mm on a CoreXY and Ø + 0.4 on a modern bedslinger (Real printed clearances, Why holes print small). The magnet is glued in with cyanoacrylate or epoxy, or enclosed during a pause; never press-fitted, because sintered NdFeB chips and cracks. What matters for the mechanism is where the wall that adds to the gap ends up.

Option A, the mating face on the bed. Use it whenever the part allows. The wall over the magnet is a floor: the first layers, printed on a flat sheet, dense and exactly to thickness. The pocket opens away from the face and the magnet is glued in after printing, with no pause. A floor of 2–3 layers (0.4–0.6 mm at 0.20 mm layers) is the thinnest that reliably prints closed and flat; check that the first layer is not see-through. Elephant's foot does no harm here; flatness is what counts (The face on the bed).

Option B, the mating face on top. The wall is a roof over the pocket. Never print it as a bridge over the empty pocket: it sags and adds gap exactly where it costs most. Pause the print, drop the magnet in and print the roof (3 layers or more) over it, with the pause layer at least 0.1 mm above the magnet. That tenth counts toward the gap too: a 0.6 mm roof means 0.7 mm between magnet and face. Before you drop a magnet in mid-print, check that your firmware really pauses on the command the slicer writes (Embedding magnets and nuts mid-print).

The third option is an exposed magnet: glued into an open pocket and recessed 0.1–0.2 mm below the face, so that two exposed magnets do not strike each other (impacts chip NdFeB). The pair's gap comes out at 0.2–0.4 mm, the force is at its highest and the magnet shows. Do not use it on anything that could end up in a child's hands: two swallowed neodymium magnets attract each other through the intestinal wall. In a toy the magnet is enclosed (option B or a plug), and toy safety standards (EN 71-1 in Europe, ASTM F963 in the United States) restrict small accessible magnets.

AGlue2–3 layer floorMating faceNo pauseBPause3-layer roofPause ≥ 0.1 mm above magnetMating face✗BedNot like thisPull forceKnockFriction = μ·FLip 1.5–2 mm
Two ways to seat a catch magnet. A: mating face on the bed, a 2–3 layer floor and the magnet glued in afterwards, no pause. B: mating face on top, the roof laid over the magnet after a pause, never a bridge over the empty pocket. Below, the inner lip takes the side knock.

As for heat, N35–N45 grades hold to about 80 °C; N50–N52 only to 60–65 °C; H grades to about 120 °C and SH to about 150 °C. Those figures are for thick magnets: a thin disc such as the Ø6 × 2 demagnetizes before it reaches its rated maximum, so leave margin below it or use an H grade. The risk is hours over a hot bed during a pause, or a part left in a car in summer. PLA softens sooner, around 55–60 °C, and cyanoacrylate loses grip with heat (Heat, cold, sunlight and chemicals). Since April 2025 the dysprosium and terbium grades, which are the high-temperature ones, need a Chinese export license, and as of late 2026 they usually cost noticeably more than the N grades: check the supplier's price.

Worked example: a box lid

A 100 × 60 mm box with a PLA lid of about 15 g (0.15 N). Two Ø6 × 2 N45 discs in the box and two Ø6 × 2 steel discs in the lid (or two magnets, with polarity as a key). Pull per magnet according to the supplier: 7.26 N against thick steel. The box rim, about 2 mm wide, cannot take a Ø6.4 hole: each magnet goes in a boss or a solid corner at least 9–10 mm across.

Requirements: the lid stays shut when you shake the box upside down (3 times its weight, about 0.45 N) and opens comfortably with a fingernail on a tab (under about 10 N in total, a judgment rather than a measurement).

Read off the curve above, as an order of magnitude. It is the Ø6 × 3 curve, but a Ø6 × 2 behaves almost the same, which is close enough here:

Lid with two Ø6 × 2 N45 magnets: estimate by layout
Layout Gap Force left Per magnet Total Margin over 0.45 N
B: 0.6 roofs + 0.1 pause on each side, 0.1 air 1.5 mm ~32 % ~2.3 N ~4.6 N ×10
Mixed: 0.4 floor in the lid (on the bed), 0.6 roof + 0.1 pause in the box, 0.1 air 1.2 mm ~40 % ~2.9 N ~5.8 N ×13

Option A on both parts only works if both print with the mating face on the bed, and the box cannot: upside down, its 100 × 60 floor would be a bridge over the whole cavity. So the box face is a roof after a pause, and only the lid gets a floor. Both layouts pass comfortably and open by hand. The mixed one gives about 25 % more force (5.8 against 4.6 N) from the same magnets and saves the pause in the lid. With the box magnets exposed, recessed 0.1 mm, the gap drops to 0.6 mm and the force rises to about 9 N in total, at the limit of easy opening. The percentages come from interpolating on the curve (the 32 % between 45 % at 1 mm and 20 % at 2 mm); all of it is order of magnitude. With margins like these, holding upside down does not drive the design: easy opening and the side knock do.

Now for what the table does not show. The steel discs in the lid fall short of the catalog's thick plate, so the real force will be lower: that is what the coupon is for. Then the side check: sideways, the lid holds only through plastic-on-plastic friction, around 0.3–0.5 × 5.8 ≈ 1.7–2.9 N in the mixed layout, and not reliably. Add a 1.5–2 mm locating lip inside the box rim and the plastic takes the knock. The rest of the lid (hinges, seals, tabs) is in Enclosure lids.

Magnetic detents: positions without a spring to fatigue

A magnetic detent is built in one of two ways.

Face to face: magnets in the rotor ring facing magnets (or steel) in the stator ring, with a gap between them. With n magnets in each ring, all oriented the same way, or facing n pieces of steel (pins, discs), you get n rest positions. A continuous steel ring or washer gives none: the rotor feels no difference as it turns. If both rings alternate N and S, only n/2 attracting positions remain, with a repelling one between each pair: the click is crisper.

Ball detent with a magnet instead of a spring: the steel ball rides in a bore in the moving part and the fixed part carries the notches, with a magnet under each one pulling the ball in. Put the magnet behind the ball, in the moving part, and it pulls the ball toward itself and away from the notches. The geometry of the mechanical detent is in Ball and spring detents; the wedge equation is the same:

F_r ≈ F_m·(tan θ + μ) / (1 − μ·tan θ)

θ is the notch flank angle measured from the direction of travel. At 45° the detent is firm, at 30° soft, and at 60° or more it locks. For steel on printed plastic, start with μ = 0.2–0.35 and then measure. On a knob, the holding torque is T = F_r·R.

Unlike a spring force, which rises as the ball climbs out, F_m drops, because the ball moves away from the magnet. At 45° the ball rises 0.29 times its radius before it clears the notch. So F_m is the force with the ball seated and F_r is a peak: past that point, the ball jumps with no resistance.

Say you measure F_m = 2 N with the ball seated (an example value; yours comes from measuring), with θ = 45° and μ = 0.3. F_r ≈ 2·1.3 / 0.7 ≈ 3.7 N. With the notch at R = 12 mm, T ≈ 45 N·mm.

Two face-to-face detents running: on the left, six magnets per ring all the same way round; on the right, N and S alternating. The hand turns each rotor slowly up to half a position and the magnets snap it into the next: six positions on the left, three on the right
The positions come from the polarity pattern. Two knobs with six Ø6 magnets per ring, the rotor (orange) over the stator (gray); each magnet marked by the face toward the other ring: N a full disc, S a ring. On the left, all the same way round (or steel pieces): one position per magnet, every 60°. On the right, N and S alternating in both rings: half as many, every 120°, separated by a repulsion where like poles meet. The hand (blue arrow) turns the knob slowly up to half a position and the magnets snap it into the next.

In the face-to-face detent, the same magnets that give the click pull the rotor against the stator. That axial force, times μ and the mean radius, is a friction torque that blurs the click. Set the gap with a shoulder or a thrust face so the magnets never touch, and count that force when you size the knob's bearing face (Friction and wear).

If the pitch between positions is close to the gap or to the magnet size, the rotor sees an almost uniform ring and the positions blur into each other. As an estimate, leave a pitch of at least 1.5–2 times the magnet diameter and a gap much smaller than that pitch; the coupon confirms it. A magnetic detent suits a few well-spaced positions; for many close together, the mechanical one wins.

Repulsion used as a spring or a return always needs a guide. No arrangement of fixed magnets holds a part in stable equilibrium by repulsion alone (Earnshaw's theorem): the part escapes sideways. For a bistable, see Compliant bistables.

Polarity: decide it on the drawing, check it dry

A magnet does not show its poles. Fitted by eye, you get the polarity right half the time, and a magnet that is glued or enclosed can no longer be flipped. Decide the polarity of each pocket on the drawing. Take the magnets from a single stack, so they all have the same face up. Mark a reference magnet with a dot. Test the pair dry, in their pockets, before the glue.

Print a mark next to each pocket (a dot or a notch) showing which pole faces out: that way you can follow the drawing at the bench.

Handle them with plastic or brass tweezers. A magnet jumps to any nearby steel: the hardened steel nozzle during the pause, or the bed sheet.

When it fails

Symptom, cause and fix
Symptom Cause Fix
Closes without force Wall too thick, roof bridged and sagging, or the lid lip bottoms out before the magnets The thinnest wall that prints flat, mating face on the bed, magnets as the last contact
Lid slides off when knocked Sideways, only friction holds, μ·F Lip or locating pins
Repels, or only closes one way round Polarity reversed, or a polarity key you did not want Test dry before gluing and mark the polarity
Magnet falls out Pressed in and chipped, or cyanoacrylate softened by heat Ø + 0.3/0.4 and epoxy, or enclosed under a roof; in a toy, always enclosed
Loses force after a summer or after printing on a hot bed Thermal demagnetization (N50–N52 above 60–65 °C; sooner in thin discs) Grade to suit the temperature, bed at PLA temperature, or an H grade
Magnet will not grip the screw or washer A2/A4 stainless, barely magnetic Zinc-plated steel
Chipped magnet edge Exposed magnets striking each other Recessed 0.1–0.2 mm, or covered
Soft detent, no click Axial friction from face contact, pitch too short, or continuous steel instead of separate pieces Gap fixed by a shoulder, pitch of 1.5–2 diameters, steel in separate pieces
Rest position has shifted A steel screw or insert nearby Move it several magnet diameters away

How to test it

Start with a roof coupon: a bar with five pockets under walls of 0.2 / 0.4 / 0.6 / 0.8 / 1.0 mm, printed on your machine, with your magnet. Pull each magnet off a steel plate (or off its real partner): five pulls, and keep the lowest. A luggage scale reads poorly below 100–200 g, and here you are dealing with about 300–650 g per magnet with a Ø6 × 2: set the steel on a zeroed kitchen scale and pull the magnet upwards (the reading drops until the moment it lets go), or use a 10 N force gauge. In 20 minutes you have your own curve, which replaces every estimate above (Test coupons).

Then, on the assembly, measure the closing force, the opening force and the side push that makes the lid slide. On a detent, measure the release torque by pulling with the force gauge on a lever at a known radius.

For heat, leave the part for an hour at its service temperature (in a car in the sun, next to a motor), let it cool and repeat the pull. A loss that does not recover is demagnetization. The full method is in Testing a mechanism before you trust it.

See also

Design it in KapyCAD

Model the joint with these dimensions. Each one stays a value you can change after the first test print.

Free plan, no card. Runs in your browser, nothing to install.

Open the editor

Still have a question?