3D Printing Generator
DeutschEnglish

Bayonet box: a round box with a twist-and-click lid

A round box with a bayonet lid

A bayonet box closes the way a camera lens does: the lid slides straight down over the neck of the box, a short twist locks it, and a small bump makes it click. There is no thread to cross, so the lid is on in a second and still stays shut in a pocket or a backpack. This generator builds that round box around the size you need: a pill box, a case for earplugs or coin cells, a small parts box with compartments, a tall tube for drill bits.

You choose the diameter and height, the number of lugs, optional pie-shaped compartments, and whether the body is slim or has grip grooves. You can also turn the star engravings on the bottom and on the lid on or off. Box and lid appear side by side in the 3D preview, ready to print, in one or two colors.

Browse the examples first: the pill box, the guitar pick box or the bead box with five compartments. Each one opens in the editor with one click.

Please read this first

  • Print with supports off. The lugs have 60° flanks, as the thread of a bottle cap has. PrusaSlicer’s automatic supports mark small regions under them. These flanks are the locking faces of the design, and the gap between them is only a fraction of a millimeter, so supports would spoil exactly the surfaces that matter. The slicing numbers below show how little the slicer would add anyway.
  • We have not test-printed this box. The geometry was compared with the original OpenSCAD file, the fit of lid and box was checked on the computer, and every example was sliced in PrusaSlicer. None of that replaces a real print, so start with a small box and adjust the clearance.
  • Pills and food: we make no food-safety claims. Printed parts have layer lines that hold moisture and dirt, and ordinary filament is not certified for contact with food or medication.
  • Small parts: the lid, the lugs and the things you keep inside are a choking hazard for small children and pets. Keep the boxes out of their reach.

How the generator works

The generator runs in your browser. Nothing is uploaded, and your design is stored in the link: use “Share” to send exactly this box to somebody or to bookmark it. Every change shows in the 3D preview right away.

  1. Under “Size”, choose the “Diameter” and the “Height”, and say what the diameter means.
  2. Under “Inside and decor”, set the “Compartments”, and toggle “Slim body” and the two stars.
  3. Under “Bayonet lock”, set the “Lugs”, the “Wall” and the “Clearance”.
  4. Pick the colors, choose “Parts” and download an STL or a 3MF.

The line next to the “Size” heading shows the outside diameter and the inside space, for example “Ø 32.6 mm, inside Ø 25.5 × 13 mm” for the default box.

Size: inside, outside and height

“Diameter” runs from 15 to 90 mm. “Diameter counts” decides what it means: Inside is the free diameter of the cavity, what has to fit in. Outside is the largest width of the finished box, what it has to fit into, like a cup holder or a drawer compartment. The other value follows from the wall, the lugs and the clearance. The jar with a 60 mm outside diameter uses the outside mode and has 52.9 mm of space inside.

With the default wall of 0.85 mm and clearance of 0.35 mm, the outside is 7.1 mm wider than the inside. The wall counts twice, because the lid slides over the neck of the box, and the lugs take 1.5 mm each side. If you enter an outside diameter that would leave less than 15 mm inside, the generator raises it and tells you.

“Height” (10 to 120 mm) is the height of the closed box with the lid. The box part alone is 1 mm lower, and the lid is 6 mm tall. The inside is always 2 mm lower than the closed height, because floor and lid top take 1 mm each: a 15 mm box has 13 mm of free space, a 25 mm box has 23 mm.

Lugs, wall and clearance

“Lugs” can be 3 to 6. With three lugs, the lid turns about a sixth of a turn; with more lugs the turn is shorter, but each lug is shorter too. Very small boxes cannot take as many lugs, because the lugs of box and lid would no longer pass each other. The generator then uses fewer and shows a message. Two lugs are not offered, because their long turn makes the lugs wedge before the detent.

“Wall” (0.8 to 1.6 mm, default 0.85 mm) is the wall thickness of box and lid. The default is two lines of a 0.4 mm nozzle. The earbud case uses 1.2 mm to take some knocks in a jacket pocket.

“Clearance” (0.25 to 0.6 mm, default 0.35 mm) is the play between lugs and walls. A little more turns easier, a little less holds tighter. If the lid sticks, raise it by 0.05 mm; if it rattles, lower it. The mechanism has small detent bumps on the lid and stops on the box, so the lid ends in a defined place. With an even number of lugs the stops and bumps are turned half a lug pitch, so that they line up. This is a change from the original, which only fits odd lug counts.

Body, compartments and decoration

Slim body. With “Slim body” on (default), the body below the lid is as narrow as the neck, with a flared collar under the lid. With it off, the body is full width and has slanted grip grooves, which help with small boxes you hold with two fingers: the coin cell box and the small 20 × 10 mm box use it. Boxes up to 11 mm tall always get the full body, because the slim shape needs a little height.

Compartments. “Compartments” (0 to 5) splits the inside into pie-shaped chambers with a small hole in the middle, such as the five-compartment bead box or the three-compartment screw box. 0 gives one open space. A box that is too narrow gets no compartments and shows a message.

Stars. “Star under the box” and “Star on the lid” engrave a seven-pointed star 0.5 mm deep. Both are on by default. They lie on the bed when printed, so they show as a neat pattern. Switch them off for a plain surface, as in the spare lid.

“Parts” prints “Both”, only the “Box” or only the “Lid”. For large boxes, box and lid sit diagonally on the plate so that both fit on a 180 mm bed.

Colors

There are two color slots: “Box” and “Lid”. Leave the lid color empty and the whole thing is one color. Set both and the download holds two parts, each assigned to its own extruder. Pick “Multi-color 3MF (PrusaSlicer)”, “3MF (Bambu Studio / OrcaSlicer)” or “STL per color (ZIP)”. The two-color box shows a white box with an orange lid.

Box and lid are separate parts, so they do not touch while printing. With a single nozzle, there is no clever trick: print them as two jobs, one with “Parts” set to “Box” and one set to “Lid”, and swap the filament in between.

Printing tips

  • Orientation: as the generator lays them out. The box stands upright on its bottom, the lid lies with its top on the bed.
  • Supports: off. The auto-support numbers in the table are what a slicer would add.
  • Layer height: 0.2 mm. The lugs are modeled in 0.2 mm slabs.
  • Material: PLA is the easiest. PETG works as well; if it is stringy or too tight, raise “Clearance” by 0.05 mm.
  • First print: try a small box first, such as the coin cell box, and check that the lid turns and clicks before you print a big one.
  • Numbers from a real slice on a Prusa MINI with “0.20mm SPEED” and Prusament PLA (minutes rounded):
ExampleInside Ø × heightFilamentTime
Pill box25.5 × 13 mm4.2 g23 min
Earplug case30 × 22 mm6.0 g34 min
Coin cell box21 × 10 mm3.6 g20 min
Guitar pick box35 × 14 mm6.4 g29 min
Bead box50 × 18 mm13.6 g50 min
Screw box40 × 23 mm10.4 g45 min
Drill bit tube30 × 102 mm19.0 g2 h 9 min
Spice jar40 × 33 mm10.1 g51 min
Earbud case55 × 26 mm16.9 g57 min
Two-color box35 × 18 mm6.9 g33 min
Spare lidlid only1.7 g8 min

With automatic supports turned on, the slicer would add 0.05 to 0.25 g per example: small islands under the lugs, three per part, and a tiny speck on the lid. We left them off on purpose, for the reason above.

Which box when?

  • The box with friction-fit lid is the all-purpose box: any inner size, a push-in lid and a grid of compartments.
  • The screw-top jar closes with a full thread, which needs more turns and holds more tightly.
  • The weekly pill organizer has a chamber and a lid for every day of the week.
  • This generator is for small to medium round boxes that you open and close often with one short twist.

Origin and licenses

The generator is a port of Bayonet lock Box by Jack (Ulrich Bär) on Printables, published under CC0. It ports the file 23-323-TwistLock.scad and uses the matching parts of the CC0 library UB.scad by the same author as TypeScript code. We compared the result with the OpenSCAD original on twelve parameter sets: the volumes agree within 0.2 %, the outer dimensions within 0.01 mm.

Our changes: three to six lugs instead of a fixed number, with fewer on small boxes; stops and detent bumps adapted for even lug counts; the lid placed next to the box instead of overlapping it; a minimum clearance of 0.25 mm; the outside diameter raised so that at least 15 mm stay free; and the clearance, wall, compartment and color options in the editor. Both sources are CC0, so there are no conditions; the credits are a courtesy. All licenses are listed on the licenses page.

Try it right away in the generator and browse the examples.

All parameters

The numeric settings of the generator with their default values and allowed ranges. Text, fonts, patterns and colors are set directly in the generator.

ParameterDefaultRangeMeaning
Size
Diameter25.5 mm15 – 90 mmInside or outside diameter of the box, as chosen above. The other one follows from the wall, the lugs and the clearance.
Height15 mm10 – 120 mmHeight of the closed box, lid included. The inside is 2 mm lower (floor and lid top).
Inside and decor
Compartments00 – 5Pie-shaped compartments with a small hole in the middle; 0 leaves one open space.
Bayonet lock
Lugs33 – 6Number of bayonet lugs. Small boxes get fewer when the lugs would not pass each other.
Wall0.85 mm0.8 – 1.6 mmWall thickness of box and lid (source: 0.85 mm, two lines of a 0.4 mm nozzle).
Clearance0.35 mm0.25 – 0.6 mmPlay between the lugs and the walls. More turns easier, less holds tighter; 0.35 mm suits most printers.

Frequently asked questions

Do I need supports?

No, turn them off. The lugs on box and lid have 60° flanks, like a thread, and PrusaSlicer’s automatic supports flag tiny regions under them (about 0.05 to 0.25 g per part). Those flanks are the faces where lid and box lock, so support material there would leave a rough surface exactly where the parts meet. This is how the original design is built.

How do I close the box?

Put the lid on so that its lugs sit in the gaps between the lugs of the box, push it down and turn it clockwise until it clicks. The turn is about 180° divided by the number of lugs: 60° with three lugs, 45° with four. To open it, turn the lid counterclockwise past the small detent bumps.

Is the box safe for pills or food?

We make no food-safety claims. Layer lines hold moisture and dirt, and a regular filament is not certified for contact with food or medication. If you keep something you swallow or eat in it, that is your own decision. The box is also a small-parts container: the lid and its contents are a choking hazard for small children and pets.

Which diameter do I enter?

Use “Diameter counts” to say whether the number is the inside, which is what has to fit in, or the outside, which is what the box has to fit into. With the default wall and clearance the outside is 7.1 mm wider than the inside, because box wall, lid wall, the lugs and the play all sit on the radius. The inside height is always 2 mm less than the closed height.

The lid is too tight or too loose. What now?

Change “Clearance” by 0.05 mm and reprint only the lid, using “Parts” set to “Lid”. More clearance turns more easily, less holds tighter; the default is 0.35 mm and the range is 0.25 to 0.6 mm. Printers differ, so check with a small box first, because we have not test-printed this design ourselves.

Can I print it in two colors?

Yes. Box and lid are two color slots: “Box” and “Lid”, and an empty lid color takes the box color. Download the multi-color 3MF for PrusaSlicer, the 3MF for Bambu Studio or OrcaSlicer, or one STL per color. On a single-nozzle printer, print the box and the lid as two jobs.

Origin & license

  • Bayonet lock Box by Ulrich Bär (Jack) · CC0 1.0 · code ported – Ported from 23-323-TwistLock.scad: box with neck, three bayonet lugs with lead-in, stops and fillet, slim body with collar or full body with grip grooves, pie-shaped compartments, star under the floor; lid with knurl, inner lugs and detent bumps. Adapted: three to six lugs, fewer on small boxes when they cannot pass each other; with an even lug count the stops and detent bumps turn with the lugs; lid next to the box instead of overlapping it.
  • UB.scad by Ulrich Bär (UBaer21) · CC0 1.0 · helper code ported – Pille, Anschluss, Kehle, Ring, RingSeg, Polar, Knurl, SWelle, Roof and Gewinde (GewindeV4) ported to TypeScript as sections