bambu3mf
Python library for creating BambuStudio-compatible 3MF project files. Supports multi-plate layouts, per-object extruder assignment, and printer/filament preset configuration.
Installation
pip install bambu3mf
Requires Python 3.10+ and lib3mf.
lib3mf publishes wheels only for Linux x86_64, macOS, and Windows x86_64. On other platforms, such as Linux on ARM, pip install fails.
Quick Start
from bambu3mf import BambuProject
project = BambuProject(
printer_settings_id="Bambu Lab P1P 0.4 nozzle",
filaments=[
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#FF0000"},
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#0000FF"},
],
)
plate = project.add_plate(name="My Plate")
plate.add_stl("body.stl", extruder=1)
plate.add_stl("accent.stl", position=(150, 100), extruder=2)
project.save("output.3mf")
Open output.3mf in BambuStudio and it will load with correct plate layout, filament colors, and printer preset -- ready to slice.
Examples
Single Object, Auto-Centered
from bambu3mf import BambuProject
project = BambuProject()
plate = project.add_plate()
plate.add_stl("model.stl") # centered on bed automatically
project.save("simple.3mf")
Multi-Plate Project
from bambu3mf import BambuProject
project = BambuProject(
printer_settings_id="Bambu Lab X1 Carbon 0.4 nozzle",
filaments=[{"settings_id": "Bambu PLA Basic @BBL X1C", "colour": "#FFFFFF"}],
)
p1 = project.add_plate(name="Base Parts")
p1.add_stl("base_left.stl", position=(10, 10))
p1.add_stl("base_right.stl", position=(140, 10))
p2 = project.add_plate(name="Top Parts")
p2.add_stl("top.stl")
project.save("multi_plate.3mf")
Plates are arranged in a grid layout matching BambuStudio's internal algorithm. Objects are assigned to plates by spatial position.
Multi-Color Print
from bambu3mf import BambuProject
project = BambuProject(
printer_settings_id="Bambu Lab P1S 0.4 nozzle",
filaments=[
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#000000", "type": "PLA"},
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#FF5733", "type": "PLA"},
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#FFFFFF", "type": "PLA"},
],
)
plate = project.add_plate()
plate.add_stl("frame.stl", extruder=1) # black
plate.add_stl("logo.stl", position=(80, 80), extruder=2) # orange
plate.add_stl("text.stl", position=(80, 120), extruder=3) # white
project.save("multicolor.3mf")
Custom Bed Size (A1 Mini)
from bambu3mf import BambuProject
project = BambuProject(
bed_size=(180, 180),
printer_settings_id="Bambu Lab A1 mini 0.4 nozzle",
)
plate = project.add_plate()
plate.add_stl("small_part.stl")
project.save("a1_mini.3mf")
Description Metadata
from bambu3mf import BambuProject
project = BambuProject(
description="<p>Print-in-place gearbox with 0.2mm clearance.</p>",
)
plate = project.add_plate(name="Main")
plate.add_stl("gearbox.stl")
project.save("described.3mf")
description is written to <metadata name="Description">...</metadata> in 3D/3dmodel.model. If the value contains HTML-like text, it is XML-escaped in the 3MF archive.
Slicing with the BambuStudio CLI
The BambuStudio CLI needs complete settings in the file. It segfaults on a file that holds only preset names.
When printer_settings_id is set, save reads the system presets of the installed BambuStudio and writes the complete settings. print_settings_id and the filament presets default to the defaults of the printer.
project = BambuProject(
printer_settings_id="Bambu Lab P1P 0.4 nozzle",
print_settings_id="0.20mm Standard @BBL P1P",
filaments=[{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#FF0000"}],
)
project.add_plate().add_stl("part.stl")
project.save("part.3mf")
BambuStudio --slice 0 --outputdir "$PWD/out" --export-3mf sliced.3mf part.3mf
savefinds the profile folder on macOS and Windows. On other systems, passprofiles_dir(theresources/profilesfolder of BambuStudio).- If no profile folder is found,
savewrites only the preset names. The GUI can open that file. The CLI cannot. - If a preset name is not in the profile folder,
savegives a warning and writes only the preset names. bed_sizedefaults to theprintable_areaof the printer preset. If you passbed_size, it must match the printer.
API Reference
BambuProject
BambuProject(
*,
bed_size=None, # (width, height) in mm (default: from the printer preset, else 256 x 256)
printer_settings_id="", # BambuStudio printer preset name
filaments=None, # list of filament dicts (see below)
app_version=None, # override Application metadata
description=None, # optional 3MF Description metadata (HTML text is XML-escaped)
profiles_dir=None, # BambuStudio profile folder (default: the installed app)
)
Filament dicts accept these keys:
| Key | Default | Description |
|---|---|---|
settings_id |
"" |
BambuStudio filament preset name |
colour |
"#00AE42" |
Hex color shown in slicer UI |
type |
"PLA" |
Material type |
diameter |
"1.75" |
Filament diameter in mm |
Methods:
add_plate(*, name=None)-- Create a new plate. Returns aPlate. Plates are 1-indexed.save(path)-- Write the 3MF file.
Plate
Created via project.add_plate(). Do not instantiate directly.
Methods:
add_stl(path, *, position=None, extruder=1)-- Load an STL onto this plate.position:(x, y)in mm for the object's min corner, relative to plate origin.Noneto auto-center.extruder: 1-indexed filament slot.- Returns a dict with
resource_id,vertex_count,triangle_count,bounding_box. - Raises
FileNotFoundErrorif the STL doesn't exist. - Raises
ValueErrorif the object exceeds bed bounds at the given position.
How It Works
The library generates a valid 3MF ZIP archive containing:
| File | Format | Purpose |
|---|---|---|
3D/3dmodel.model |
XML | Mesh geometry with BambuStudio namespace |
Metadata/project_settings.config |
JSON | Printer, filament, and bed configuration |
Metadata/model_settings.config |
XML | Per-object metadata and plate layout |
Mesh geometry is handled by lib3mf. BambuStudio-specific metadata (namespace, version, config files) is injected post-write since lib3mf has no API for custom namespaces.
Key compatibility detail: BambuStudio assigns objects to plates by spatial bounding-box intersection, not by the plate-to-object mapping in config. The library handles this automatically by positioning objects in the correct grid cell.
Development
pip install -e ".[dev]"
pytest
License
See LICENSE for details.
Metadata
Release files for bambu3mf 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bambu3mf-0.1.0.tar.gz | 27.7 kB | With provenance | Details for bambu3mf-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bambu3mf-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bambu3mf-0.1.0-py3-none-any.whl |
Total release size: 45.9 kB
Release files / bambu3mf-0.1.0.tar.gz
| Download URL | bambu3mf-0.1.0.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ddc71f97e026de5eb0c02c567af9cf5d8c606dcc7462c92ee87102f1e1afe9a
|
|
BLAKE2b-256 checksum How to use checksums |
4f53f0069f03a7c49e5d7a96397cb17ecbd9d7246445e0624e3fb5c2511e843c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / bambu3mf-0.1.0-py3-none-any.whl
| Download URL | bambu3mf-0.1.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0cd719472aeca32669003e6b10e6296de4f641ef744cf45c469b1864bb231a2a
|
|
BLAKE2b-256 checksum How to use checksums |
5eef29bae5b40b2c96ed17c47f71bc21fcd9ed4df08651dfb4df8d7b2c22ec41
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for bambu3mf 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for bambu3mf-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.