Parametric 3D modeling from the terminal that produces print-ready .3mf files for
Bambu Studio and any 3MF slicer.
A .3mf is just a ZIP of plain-text geometry: a list of (x, y, z) vertices in
millimeters and a list of triangles indexing them, plus the slicer's print settings
riding along. This is a small, dependency-light Python library (b3d) for generating
good triangles, validating that the result will actually print, and packing it into a
.3mf you open directly in your slicer.
No CAD GUI, no STEP kernel, no cloud. Just code in, printable solid out.
| SDF-sculpted skeleton hand | Gnarled bone variant | Parametric wall plaque |
|---|---|---|
![]() |
![]() |
![]() |
All generated in code with b3d — organic hands via the signed-distance-field
sculptor, the plaque via parametric solids + booleans.
- Primitives: box, rounded box, cylinder, cone, pyramid, tube, sphere, prism, torus
- 2D → 3D: extrude and revolve arbitrary profiles for custom cross-sections
- Boolean ops: union / difference / intersection (manifold-exact when
manifold3dis installed, with a pure-Python BSP fallback) - Text: emboss/deboss real font outlines onto a part, or generate standalone signs
- Validation: watertight / manifold / print-ready checks before you ever slice
- 3MF I/O: write from scratch, or swap new geometry into an existing
.3mfwhile keeping its dialed-in print profile byte-for-byte - Convert & inspect:
.3mf↔.stl, unpack/repack for hand-editing, PNG previews
Requires Python 3.9+.
git clone https://github.com/wickdninja/bambu-labs.git
cd bambu-labs
pip3 install -r requirements.txtnumpy and Pillow are needed for rendering previews. manifold3d (robust booleans)
and fontTools (text) are optional but recommended. Everything still works without the
optionals, just with a slower boolean fallback and no text.
Write a short script — you're writing CAD, so write code:
import sys; sys.path.insert(0, "scripts")
from b3d import primitives as P, csg, threemf as T
body = P.box(60, 40, 12) # mm
holes = [P.cylinder(radius=2.5, height=20, segments=48) # M5 clearance
.translated(x, y, -1) for x, y in [(-22,-13),(22,-13),(22,13),(-22,13)]]
plate = csg.difference(body, *holes) # drill 4 corners
assert plate.validate()["print_ready"] # gate before writing
T.write_simple(plate, "plate.3mf", printer="x1c", title="Mounting Plate")Or use the CLI for one-shot operations:
python3 scripts/bambu3d.py make cylinder radius=10 height=25 -o cup.3mf --printer x1c
python3 scripts/bambu3d.py make rounded_box x=60 y=40 z=10 radius=5 -o case.3mf
python3 scripts/bambu3d.py text "HELLO" --size 15 --height 4 -o sign.3mf
python3 scripts/bambu3d.py inspect model.3mf # stats + health
python3 scripts/bambu3d.py render model.3mf out.png # preview without a slicer
python3 scripts/bambu3d.py validate model.stl # exit 0 if print-ready
python3 scripts/bambu3d.py swap template.3mf new.stl -o out.3mf --name Widget
python3 scripts/bambu3d.py stl model.3mf model.stl
python3 scripts/bambu3d.py unpack model.3mf ./dir # hand-edit, then `pack`Pass printer= to center the model on the right bed. Known sizes:
| Key | Bed (mm) |
|---|---|
x1c x1 p1s p1p a1 generic |
256 × 256 |
a1mini |
180 × 180 |
h2d |
350 × 320 |
mesh.validate() returns a report. The two fields that matter:
ok— strictly manifold: watertight, consistent winding, outward normals, no degenerate faces. Primitives, extrudes, revolves, andmanifold3dbooleans hit this.print_ready— a closed solid with positive volume and no genuine gaps. Tolerates T-junctions that slicers auto-repair on import. This is the real bar for "will it slice." Never ship a file that fails this.
scripts/
b3d/ the library: mesh, primitives, extrude, csg, text, threemf
bambu3d.py CLI for routine one-shot operations
selftest.py regression suite — run after editing the toolkit
references/
3mf-format.md the 3MF/OPC format in depth
bambu-container.md Bambu's specific files + the template-swap recipe
toolkit-api.md full b3d API + a cookbook of real parametric parts
SKILL.md Claude Code skill manifest (see below)
Run the regression suite any time you change the library:
python3 scripts/selftest.pyThis repo doubles as a Claude Code skill. Clone it into your skills directory (or symlink it) so Claude can drive the toolkit for you:
git clone https://github.com/wickdninja/bambu-labs.git ~/.claude/skills/bambu-labsThen just ask Claude things like "model a 60×40 mounting plate with four M5 holes and
make it printable." SKILL.md is the manifest that tells Claude how to use the library.
- No exact curved-surface kernel (NURBS/STEP). Curves are tessellated; raise
segmentsfor smoother round parts at the cost of triangle count. - 3D fillets (rounding top/bottom edges) aren't supported. Rounded vertical edges are
(
primitives.rounded_box). swap_intoreplaces the first mesh in a multi-object.3mf. For multi-body files, unpack and edit the specific object, or rebuild from scratch.- Color/paint, supports, and multi-plate layouts are preserved on a template swap but not generated from scratch.
MIT. See LICENSE.
Not affiliated with or endorsed by Bambu Lab. "Bambu" and "Bambu Studio" are trademarks
of their respective owner; this project just writes the open .3mf format their slicer
reads.


