Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

wickdninja/bambu-labs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

bambu-labs

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
skeleton gnarled plaque

All generated in code with b3d — organic hands via the signed-distance-field sculptor, the plaque via parametric solids + booleans.

Features

  • 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 manifold3d is 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 .3mf while keeping its dialed-in print profile byte-for-byte
  • Convert & inspect: .3mf.stl, unpack/repack for hand-editing, PNG previews

Install

Requires Python 3.9+.

git clone https://github.com/wickdninja/bambu-labs.git
cd bambu-labs
pip3 install -r requirements.txt

numpy 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.

Quick start

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`

Printers and beds

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

Validation

mesh.validate() returns a report. The two fields that matter:

  • okstrictly manifold: watertight, consistent winding, outward normals, no degenerate faces. Primitives, extrudes, revolves, and manifold3d booleans 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.

Layout

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.py

Using this as a Claude Code skill

This 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-labs

Then just ask Claude things like "model a ×ばつ40 mounting plate with four M5 holes and make it printable." SKILL.md is the manifest that tells Claude how to use the library.

Limits

  • No exact curved-surface kernel (NURBS/STEP). Curves are tessellated; raise segments for 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_into replaces 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.

License

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.

About

Parametric terminal 3D modeling that outputs print-ready .3mf files for Bambu Studio and any 3MF slicer

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages

AltStyle によって変換されたページ (->オリジナル) /