bambu3mf 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bambu3mf/__init__.py +30 -0
- bambu3mf/config_writer.py +137 -0
- bambu3mf/plate.py +166 -0
- bambu3mf/presets.py +143 -0
- bambu3mf/project.py +245 -0
- bambu3mf/stl_loader.py +244 -0
- bambu3mf-0.1.0.dist-info/METADATA +246 -0
- bambu3mf-0.1.0.dist-info/RECORD +11 -0
- bambu3mf-0.1.0.dist-info/WHEEL +5 -0
- bambu3mf-0.1.0.dist-info/licenses/LICENSE +21 -0
- bambu3mf-0.1.0.dist-info/top_level.txt +1 -0
bambu3mf/__init__.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"""Python library for creating BambuStudio-compatible 3MF project files.
|
|
2
|
+
|
|
3
|
+
Generates 3MF archives that open cleanly in BambuStudio with full support
|
|
4
|
+
for multi-plate layouts, per-object filament/extruder assignment, and
|
|
5
|
+
printer/filament preset configuration.
|
|
6
|
+
|
|
7
|
+
Quick start::
|
|
8
|
+
|
|
9
|
+
from bambu3mf import BambuProject
|
|
10
|
+
|
|
11
|
+
project = BambuProject(
|
|
12
|
+
printer_settings_id="Bambu Lab P1P 0.4 nozzle",
|
|
13
|
+
filaments=[
|
|
14
|
+
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#FF0000"},
|
|
15
|
+
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#0000FF"},
|
|
16
|
+
],
|
|
17
|
+
)
|
|
18
|
+
plate = project.add_plate(name="My Plate")
|
|
19
|
+
plate.add_stl("model_a.stl", extruder=1)
|
|
20
|
+
plate.add_stl("model_b.stl", position=(150, 100), extruder=2)
|
|
21
|
+
project.save("output.3mf")
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
from importlib.metadata import version
|
|
25
|
+
|
|
26
|
+
from bambu3mf.plate import Plate
|
|
27
|
+
from bambu3mf.project import BambuProject
|
|
28
|
+
|
|
29
|
+
__version__ = version("bambu3mf")
|
|
30
|
+
__all__ = ["BambuProject", "Plate"]
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"""Serializers for BambuStudio 3MF config files.
|
|
2
|
+
|
|
3
|
+
Two config files are written into the 3MF archive:
|
|
4
|
+
|
|
5
|
+
``Metadata/project_settings.config`` (JSON)
|
|
6
|
+
Project-level settings: bed geometry, printer preset, and filament slots.
|
|
7
|
+
BambuStudio uses ``filament_colour`` from this file to determine the
|
|
8
|
+
filament count when loading plate data — if it is missing, the app
|
|
9
|
+
crashes with a null-pointer dereference (PartPlate.cpp:6544 calls
|
|
10
|
+
``config_loaded.option<ConfigOptionStrings>("filament_colour")->size()``
|
|
11
|
+
without a null check).
|
|
12
|
+
|
|
13
|
+
``Metadata/model_settings.config`` (XML)
|
|
14
|
+
Per-object metadata (name, extruder assignment) and plate-to-object
|
|
15
|
+
mappings. The ``<object>`` elements must appear *before* ``<plate>``
|
|
16
|
+
elements. Extruder values are 1-indexed and correspond to positions
|
|
17
|
+
in the ``filament_settings_id`` / ``filament_colour`` arrays.
|
|
18
|
+
|
|
19
|
+
Note: BambuStudio does NOT use the plate→object mapping here for
|
|
20
|
+
spatial assignment — it uses bounding-box intersection instead.
|
|
21
|
+
The mapping is used for metadata like identify_id and loaded_id.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import json
|
|
25
|
+
|
|
26
|
+
import xml.etree.ElementTree as ET
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def generate_project_config(plates):
|
|
30
|
+
"""Generate ``model_settings.config`` XML from a list of Plates.
|
|
31
|
+
|
|
32
|
+
Emits ``<object>`` elements with name and extruder metadata for each
|
|
33
|
+
object across all plates, followed by ``<plate>`` elements with
|
|
34
|
+
``<model_instance>`` children.
|
|
35
|
+
|
|
36
|
+
Object elements must come before plate elements — BambuStudio's XML
|
|
37
|
+
parser (``_handle_start_config_metadata`` in bbs_3mf.cpp:4358) uses
|
|
38
|
+
``m_curr_config.object_id`` to route metadata, and this is only set
|
|
39
|
+
after seeing an ``<object>`` start tag.
|
|
40
|
+
"""
|
|
41
|
+
root = ET.Element("config")
|
|
42
|
+
for plate in plates:
|
|
43
|
+
for obj in plate.objects:
|
|
44
|
+
extruder = str(obj.get("extruder", 1))
|
|
45
|
+
obj_el = ET.SubElement(root, "object")
|
|
46
|
+
obj_el.set("id", str(obj["object_id"]))
|
|
47
|
+
_add_metadata(obj_el, "name", obj.get("name", "Object"))
|
|
48
|
+
_add_metadata(obj_el, "extruder", extruder)
|
|
49
|
+
for part in obj.get("parts", []):
|
|
50
|
+
part_el = ET.SubElement(obj_el, "part")
|
|
51
|
+
part_el.set("id", str(part["object_id"]))
|
|
52
|
+
part_el.set("subtype", "normal_part")
|
|
53
|
+
_add_metadata(part_el, "name", part.get("name", "Part"))
|
|
54
|
+
_add_metadata(part_el, "extruder", str(part.get("extruder", 1)))
|
|
55
|
+
for plate in plates:
|
|
56
|
+
plate_el = ET.SubElement(root, "plate")
|
|
57
|
+
_add_metadata(plate_el, "plater_id", str(plate.plate_id))
|
|
58
|
+
_add_metadata(plate_el, "plater_name", plate.name)
|
|
59
|
+
for obj in plate.objects:
|
|
60
|
+
inst_el = ET.SubElement(plate_el, "model_instance")
|
|
61
|
+
_add_metadata(inst_el, "object_id", str(obj["object_id"]))
|
|
62
|
+
_add_metadata(inst_el, "instance_id", str(obj["instance_id"]))
|
|
63
|
+
_add_metadata(inst_el, "identify_id", str(obj["object_id"]))
|
|
64
|
+
return ET.tostring(root, encoding="unicode")
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
DEFAULT_FILAMENT_COLOUR = "#00AE42"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def generate_project_settings(*, bed_size, printer_settings_id="",
|
|
71
|
+
print_settings_id="", filaments=None,
|
|
72
|
+
preset_settings=None):
|
|
73
|
+
"""Generate ``project_settings.config`` JSON.
|
|
74
|
+
|
|
75
|
+
Args:
|
|
76
|
+
bed_size: ``(width, height)`` in mm. Serialized as ``printable_area``
|
|
77
|
+
rectangle corners: ``["0x0", "{w}x0", "{w}x{h}", "0x{h}"]``.
|
|
78
|
+
printer_settings_id: System preset name string.
|
|
79
|
+
filaments: List of dicts with optional keys ``settings_id``,
|
|
80
|
+
``colour`` (hex string, default ``#00AE42``),
|
|
81
|
+
``type`` (default ``"PLA"``), ``diameter`` (default ``"1.75"``).
|
|
82
|
+
preset_settings: Complete settings from
|
|
83
|
+
:meth:`bambu3mf.presets.PresetLibrary.project_settings`. When
|
|
84
|
+
given, they are the base of the file. ``type`` and ``diameter``
|
|
85
|
+
then come from the presets unless a filament dict sets them.
|
|
86
|
+
|
|
87
|
+
All filament arrays must have the same length — BambuStudio indexes
|
|
88
|
+
them by extruder number (0-based internally, 1-based in user-facing UI).
|
|
89
|
+
"""
|
|
90
|
+
w, h = bed_size
|
|
91
|
+
settings = dict(preset_settings or {})
|
|
92
|
+
settings.update({
|
|
93
|
+
"name": "project_settings",
|
|
94
|
+
"from": "project",
|
|
95
|
+
"printable_area": ["0x0", f"{w}x0", f"{w}x{h}", f"0x{h}"],
|
|
96
|
+
})
|
|
97
|
+
if preset_settings:
|
|
98
|
+
if filaments:
|
|
99
|
+
settings["filament_colour"] = [
|
|
100
|
+
f.get("colour", DEFAULT_FILAMENT_COLOUR) for f in filaments
|
|
101
|
+
]
|
|
102
|
+
for key, option in (("type", "filament_type"),
|
|
103
|
+
("diameter", "filament_diameter")):
|
|
104
|
+
settings[option] = [
|
|
105
|
+
f.get(key, preset)
|
|
106
|
+
for f, preset in zip(filaments, settings[option])
|
|
107
|
+
]
|
|
108
|
+
else:
|
|
109
|
+
settings["filament_colour"] = [DEFAULT_FILAMENT_COLOUR] * len(
|
|
110
|
+
settings["filament_settings_id"]
|
|
111
|
+
)
|
|
112
|
+
return json.dumps(settings, indent=4)
|
|
113
|
+
if printer_settings_id:
|
|
114
|
+
settings["printer_settings_id"] = printer_settings_id
|
|
115
|
+
if print_settings_id:
|
|
116
|
+
settings["print_settings_id"] = print_settings_id
|
|
117
|
+
if filaments:
|
|
118
|
+
settings["filament_settings_id"] = [
|
|
119
|
+
f.get("settings_id", "") for f in filaments
|
|
120
|
+
]
|
|
121
|
+
settings["filament_diameter"] = [
|
|
122
|
+
f.get("diameter", "1.75") for f in filaments
|
|
123
|
+
]
|
|
124
|
+
settings["filament_colour"] = [
|
|
125
|
+
f.get("colour", DEFAULT_FILAMENT_COLOUR) for f in filaments
|
|
126
|
+
]
|
|
127
|
+
settings["filament_type"] = [
|
|
128
|
+
f.get("type", "PLA") for f in filaments
|
|
129
|
+
]
|
|
130
|
+
return json.dumps(settings, indent=4)
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _add_metadata(parent, key, value):
|
|
134
|
+
"""Append a ``<metadata key="..." value="..."/>`` child element."""
|
|
135
|
+
meta = ET.SubElement(parent, "metadata")
|
|
136
|
+
meta.set("key", key)
|
|
137
|
+
meta.set("value", value)
|
bambu3mf/plate.py
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"""Plate management and spatial layout for multi-plate projects.
|
|
2
|
+
|
|
3
|
+
BambuStudio arranges plates in a grid and assigns objects to plates by
|
|
4
|
+
checking whether each object's bounding box spatially intersects a plate's
|
|
5
|
+
region — it does NOT use the plate→object mapping in model_settings.config
|
|
6
|
+
for assignment (that mapping is only used for metadata like identify_id).
|
|
7
|
+
|
|
8
|
+
Grid layout algorithm (mirrors ``PartPlateList`` in PartPlate.cpp):
|
|
9
|
+
|
|
10
|
+
* Column count = ``ceil(sqrt(plate_count))``, matching
|
|
11
|
+
``compute_colum_count()`` in ``src/slic3r/GUI/PartPlate.hpp:38``.
|
|
12
|
+
* Gap between plates = 1/5 of plate dimension (``LOGICAL_PART_PLATE_GAP``
|
|
13
|
+
in ``src/slic3r/GUI/PartPlate.cpp:52``).
|
|
14
|
+
* Stride = ``dimension * (1 + 1/5) = dimension * 1.2``.
|
|
15
|
+
* Plate origins: ``x = col * stride_x``, ``y = -row * stride_y``
|
|
16
|
+
(negative Y = downward rows).
|
|
17
|
+
|
|
18
|
+
Example layout for 5 plates on a 256mm bed (3 columns)::
|
|
19
|
+
|
|
20
|
+
Plate 1 (0, 0) Plate 2 (307.2, 0) Plate 3 (614.4, 0)
|
|
21
|
+
Plate 4 (0, -307.2) Plate 5 (307.2, -307.2)
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
import math
|
|
25
|
+
|
|
26
|
+
from bambu3mf.stl_loader import (load_stl, load_stl_as_mesh,
|
|
27
|
+
create_component_group,
|
|
28
|
+
update_build_item_plate_offset)
|
|
29
|
+
|
|
30
|
+
# Matches LOGICAL_PART_PLATE_GAP in src/slic3r/GUI/PartPlate.cpp:52
|
|
31
|
+
PLATE_GAP_RATIO = 1.0 / 5.0
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _plate_cols(plate_count):
|
|
35
|
+
"""Compute grid column count, matching BambuStudio's compute_colum_count().
|
|
36
|
+
|
|
37
|
+
Returns ceil(sqrt(plate_count)) using the same rounding logic as the
|
|
38
|
+
C++ implementation in src/slic3r/GUI/PartPlate.hpp:38-50.
|
|
39
|
+
"""
|
|
40
|
+
v = math.sqrt(plate_count)
|
|
41
|
+
r = round(v)
|
|
42
|
+
return int(r + 1) if v > r else int(r)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Plate:
|
|
46
|
+
"""A single build plate that holds objects.
|
|
47
|
+
|
|
48
|
+
Args:
|
|
49
|
+
plate_id: 1-indexed plate number.
|
|
50
|
+
name: Display name shown in BambuStudio's plate list.
|
|
51
|
+
Defaults to ``"Plate {plate_id}"``.
|
|
52
|
+
project: Parent :class:`~bambu3mf.project.BambuProject` reference,
|
|
53
|
+
used for bed_size and the shared lib3mf model.
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
def __init__(self, plate_id, *, name=None, project=None):
|
|
57
|
+
self.plate_id = plate_id
|
|
58
|
+
self.name = name if name is not None else f"Plate {plate_id}"
|
|
59
|
+
self.objects = []
|
|
60
|
+
self._project = project
|
|
61
|
+
|
|
62
|
+
def _plate_origin(self):
|
|
63
|
+
"""Compute (x, y) world-space origin for this plate's grid cell.
|
|
64
|
+
|
|
65
|
+
Must be called after all plates are added to the project, since the
|
|
66
|
+
column count depends on the total plate count.
|
|
67
|
+
"""
|
|
68
|
+
index = self.plate_id - 1
|
|
69
|
+
total = len(self._project.plates)
|
|
70
|
+
cols = _plate_cols(total)
|
|
71
|
+
col = index % cols
|
|
72
|
+
row = index // cols
|
|
73
|
+
w, h = self._project.bed_size
|
|
74
|
+
stride_x = w * (1.0 + PLATE_GAP_RATIO)
|
|
75
|
+
stride_y = h * (1.0 + PLATE_GAP_RATIO)
|
|
76
|
+
return col * stride_x, -row * stride_y
|
|
77
|
+
|
|
78
|
+
def add_stl(self, path, *, position=None, extruder=1):
|
|
79
|
+
"""Add an STL model to this plate.
|
|
80
|
+
|
|
81
|
+
Args:
|
|
82
|
+
path: Path to the STL file.
|
|
83
|
+
position: ``(x, y)`` in mm for the object's bounding-box min corner,
|
|
84
|
+
relative to this plate's origin. If None, auto-centers on the
|
|
85
|
+
plate. Raises ValueError if the object exceeds the bed bounds.
|
|
86
|
+
extruder: 1-indexed filament/extruder slot. Must correspond to an
|
|
87
|
+
entry in the project's ``filaments`` list.
|
|
88
|
+
|
|
89
|
+
Returns:
|
|
90
|
+
Dict with ``resource_id``, ``vertex_count``, ``triangle_count``,
|
|
91
|
+
``bounding_box``.
|
|
92
|
+
"""
|
|
93
|
+
from pathlib import Path as _Path
|
|
94
|
+
result = load_stl(
|
|
95
|
+
self._project._model, path,
|
|
96
|
+
bed_size=self._project.bed_size,
|
|
97
|
+
position=position,
|
|
98
|
+
)
|
|
99
|
+
self.objects.append({
|
|
100
|
+
"object_id": result["resource_id"],
|
|
101
|
+
"instance_id": 0,
|
|
102
|
+
"name": _Path(path).stem,
|
|
103
|
+
"extruder": extruder,
|
|
104
|
+
"_center_offset": result["center_offset"],
|
|
105
|
+
})
|
|
106
|
+
return result
|
|
107
|
+
|
|
108
|
+
def add_stl_group(self, stl_entries, *, position=None):
|
|
109
|
+
"""Add multiple STLs as parts of a single grouped object on this plate.
|
|
110
|
+
|
|
111
|
+
This creates a lib3mf ComponentsObject that groups the meshes, so they
|
|
112
|
+
share a single transform and move as a unit in BambuStudio.
|
|
113
|
+
|
|
114
|
+
Args:
|
|
115
|
+
stl_entries: List of ``(path, extruder)`` tuples.
|
|
116
|
+
position: ``(x, y)`` for the group's bounding-box min corner.
|
|
117
|
+
If None, auto-centers on the plate.
|
|
118
|
+
|
|
119
|
+
Returns:
|
|
120
|
+
Dict with ``resource_id`` of the component object.
|
|
121
|
+
"""
|
|
122
|
+
from pathlib import Path as _Path
|
|
123
|
+
ox, oy = self._plate_origin()
|
|
124
|
+
|
|
125
|
+
parts = []
|
|
126
|
+
meshes = []
|
|
127
|
+
for path, extruder in stl_entries:
|
|
128
|
+
result = load_stl_as_mesh(self._project._model, path)
|
|
129
|
+
meshes.append(result["mesh"])
|
|
130
|
+
parts.append({
|
|
131
|
+
"object_id": result["resource_id"],
|
|
132
|
+
"name": _Path(path).stem,
|
|
133
|
+
"extruder": extruder,
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
group = create_component_group(
|
|
137
|
+
self._project._model, meshes,
|
|
138
|
+
bed_size=self._project.bed_size,
|
|
139
|
+
position=position,
|
|
140
|
+
)
|
|
141
|
+
|
|
142
|
+
self.objects.append({
|
|
143
|
+
"object_id": group["resource_id"],
|
|
144
|
+
"instance_id": 0,
|
|
145
|
+
"name": parts[0]["name"] if parts else "group",
|
|
146
|
+
"extruder": 1,
|
|
147
|
+
"parts": parts,
|
|
148
|
+
"_center_offset": group["center_offset"],
|
|
149
|
+
})
|
|
150
|
+
return group
|
|
151
|
+
|
|
152
|
+
def _apply_plate_offsets(self):
|
|
153
|
+
"""Recompute and apply plate grid offsets for all grouped objects.
|
|
154
|
+
|
|
155
|
+
Called at save time after all plates are added and grid positions
|
|
156
|
+
are finalized.
|
|
157
|
+
"""
|
|
158
|
+
ox, oy = self._plate_origin()
|
|
159
|
+
for obj in self.objects:
|
|
160
|
+
if "_center_offset" in obj:
|
|
161
|
+
update_build_item_plate_offset(
|
|
162
|
+
self._project._model,
|
|
163
|
+
obj["object_id"],
|
|
164
|
+
obj["_center_offset"],
|
|
165
|
+
ox, oy,
|
|
166
|
+
)
|
bambu3mf/presets.py
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
"""Expand BambuStudio system preset names into complete settings.
|
|
2
|
+
|
|
3
|
+
A ``project_settings.config`` that holds only preset names opens in the
|
|
4
|
+
BambuStudio GUI, because the GUI looks the presets up by name. The CLI does
|
|
5
|
+
not. ``BambuStudio --info`` and ``--slice`` read keys such as
|
|
6
|
+
``nozzle_diameter`` and ``printable_height`` from the file without a null
|
|
7
|
+
check (``CLI::run`` in BambuStudio.cpp) and segfault when they are missing.
|
|
8
|
+
|
|
9
|
+
This module reads the system presets that ship with BambuStudio and flattens
|
|
10
|
+
them into the complete settings that the CLI needs.
|
|
11
|
+
|
|
12
|
+
Profile layout (``<BambuStudio>/resources/profiles``)::
|
|
13
|
+
|
|
14
|
+
BBL.json vendor index: name -> sub_path per preset type
|
|
15
|
+
BBL/machine/<name>.json printer presets
|
|
16
|
+
BBL/process/<name>.json process presets
|
|
17
|
+
BBL/filament/<name>.json filament presets
|
|
18
|
+
|
|
19
|
+
A preset file holds only the keys that differ from its ``inherits`` parent.
|
|
20
|
+
It can also name ``include`` templates, which add keys such as start G-code.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
import json
|
|
24
|
+
import sys
|
|
25
|
+
from pathlib import Path
|
|
26
|
+
|
|
27
|
+
_INSTALL_PROFILE_DIRS = {
|
|
28
|
+
"darwin": ["/Applications/BambuStudio.app/Contents/Resources/profiles"],
|
|
29
|
+
"win32": [r"C:\Program Files\Bambu Studio\resources\profiles"],
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
# Keys that describe the preset file itself, not a print setting.
|
|
33
|
+
_PRESET_FILE_KEYS = {
|
|
34
|
+
"type", "name", "inherits", "from", "setting_id", "instantiation",
|
|
35
|
+
"include", "description",
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PresetNotFound(KeyError):
|
|
40
|
+
"""A preset name is not in the profile folder."""
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def find_profiles_dir():
|
|
44
|
+
"""Return the profile folder of an installed BambuStudio, or ``None``."""
|
|
45
|
+
for candidate in _INSTALL_PROFILE_DIRS.get(sys.platform, []):
|
|
46
|
+
path = Path(candidate)
|
|
47
|
+
if path.is_dir():
|
|
48
|
+
return path
|
|
49
|
+
return None
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class PresetLibrary:
|
|
53
|
+
"""The system presets in one BambuStudio profile folder."""
|
|
54
|
+
|
|
55
|
+
def __init__(self, profiles_dir):
|
|
56
|
+
self.profiles_dir = Path(profiles_dir)
|
|
57
|
+
if not self.profiles_dir.is_dir():
|
|
58
|
+
raise FileNotFoundError(f"Profile folder not found: {profiles_dir}")
|
|
59
|
+
self._paths = {"machine": {}, "process": {}, "filament": {}}
|
|
60
|
+
for index_path in sorted(self.profiles_dir.glob("*.json")):
|
|
61
|
+
index = json.loads(index_path.read_text(encoding="utf-8"))
|
|
62
|
+
vendor_dir = self.profiles_dir / index_path.stem
|
|
63
|
+
for kind, paths in self._paths.items():
|
|
64
|
+
for entry in index.get(f"{kind}_list", []):
|
|
65
|
+
paths.setdefault(entry["name"], vendor_dir / entry["sub_path"])
|
|
66
|
+
|
|
67
|
+
def resolve(self, kind, name):
|
|
68
|
+
"""Return preset *name* with its parents and templates merged in.
|
|
69
|
+
|
|
70
|
+
*kind* is ``"machine"``, ``"process"``, or ``"filament"``.
|
|
71
|
+
"""
|
|
72
|
+
try:
|
|
73
|
+
path = self._paths[kind][name]
|
|
74
|
+
except KeyError:
|
|
75
|
+
raise PresetNotFound(
|
|
76
|
+
f"{kind} preset {name!r} is not in {self.profiles_dir}"
|
|
77
|
+
) from None
|
|
78
|
+
preset = json.loads(path.read_text(encoding="utf-8"))
|
|
79
|
+
merged = self.resolve(kind, preset["inherits"]) if preset.get("inherits") else {}
|
|
80
|
+
for template in preset.get("include", []):
|
|
81
|
+
merged.update(self.resolve(kind, template))
|
|
82
|
+
merged.update(preset)
|
|
83
|
+
return merged
|
|
84
|
+
|
|
85
|
+
def project_settings(self, printer, process=None, filaments=None):
|
|
86
|
+
"""Return the complete settings for a printer, process, and filaments.
|
|
87
|
+
|
|
88
|
+
Args:
|
|
89
|
+
printer: Printer preset name.
|
|
90
|
+
process: Process preset name. Defaults to the
|
|
91
|
+
``default_print_profile`` of the printer.
|
|
92
|
+
filaments: List of filament preset names. A ``None`` entry, or
|
|
93
|
+
no list, gives the ``default_filament_profile`` of the printer.
|
|
94
|
+
|
|
95
|
+
Raises:
|
|
96
|
+
PresetNotFound: A preset name is not in the profile folder.
|
|
97
|
+
"""
|
|
98
|
+
machine = self.resolve("machine", printer)
|
|
99
|
+
process = process or machine["default_print_profile"]
|
|
100
|
+
default_filaments = machine["default_filament_profile"]
|
|
101
|
+
filaments = [f or default_filaments[0] for f in filaments or default_filaments]
|
|
102
|
+
process_preset = self.resolve("process", process)
|
|
103
|
+
|
|
104
|
+
settings = _settings_of(process_preset)
|
|
105
|
+
settings["print_compatible_printers"] = settings.pop("compatible_printers", [])
|
|
106
|
+
settings.update(
|
|
107
|
+
_merge_filaments([self.resolve("filament", f) for f in filaments])
|
|
108
|
+
)
|
|
109
|
+
settings.update(_settings_of(machine))
|
|
110
|
+
settings["printer_settings_id"] = printer
|
|
111
|
+
settings["print_settings_id"] = process
|
|
112
|
+
settings["filament_settings_id"] = list(filaments)
|
|
113
|
+
return settings
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def _settings_of(preset):
|
|
117
|
+
return {k: v for k, v in preset.items() if k not in _PRESET_FILE_KEYS}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
def _merge_filaments(presets):
|
|
121
|
+
"""Join the per-filament presets into project-level arrays.
|
|
122
|
+
|
|
123
|
+
BambuStudio stores each filament setting as one array for all filaments.
|
|
124
|
+
A filament can have more than one value per setting, one for each extruder
|
|
125
|
+
variant. ``filament_self_index`` gives the 1-based filament of each value.
|
|
126
|
+
"""
|
|
127
|
+
filaments = [_settings_of(p) for p in presets]
|
|
128
|
+
merged = {}
|
|
129
|
+
for key in dict.fromkeys(k for f in filaments for k in f):
|
|
130
|
+
fallback = next(f[key] for f in filaments if key in f)
|
|
131
|
+
if isinstance(fallback, list):
|
|
132
|
+
merged[key] = [v for f in filaments for v in f.get(key, fallback)]
|
|
133
|
+
else:
|
|
134
|
+
merged[key] = fallback
|
|
135
|
+
merged.pop("compatible_printers", None)
|
|
136
|
+
merged.pop("filament_id", None)
|
|
137
|
+
merged["filament_ids"] = [f.get("filament_id", "") for f in filaments]
|
|
138
|
+
merged["filament_self_index"] = [
|
|
139
|
+
str(index)
|
|
140
|
+
for index, f in enumerate(filaments, start=1)
|
|
141
|
+
for _ in f.get("filament_extruder_variant", [""])
|
|
142
|
+
]
|
|
143
|
+
return merged
|
bambu3mf/project.py
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
"""Core project class that orchestrates 3MF file creation.
|
|
2
|
+
|
|
3
|
+
A BambuStudio 3MF archive contains:
|
|
4
|
+
|
|
5
|
+
3D/3dmodel.model Mesh geometry + BambuStudio XML namespace/metadata
|
|
6
|
+
Metadata/project_settings.config JSON with printer, filament, and bed config
|
|
7
|
+
Metadata/model_settings.config XML with per-object metadata and plate layout
|
|
8
|
+
[Content_Types].xml Standard 3MF boilerplate
|
|
9
|
+
_rels/.rels Standard 3MF boilerplate
|
|
10
|
+
|
|
11
|
+
BambuStudio compatibility notes (discovered empirically):
|
|
12
|
+
|
|
13
|
+
* The ``Application`` metadata must match the installed BambuStudio version
|
|
14
|
+
exactly, otherwise a "Newer 3mf version" warning appears. The version
|
|
15
|
+
format is ``BambuStudio-MM.mm.PP.BB`` and is parsed by a custom semver
|
|
16
|
+
library that packs the 4th component into ``patch`` via ``patch*100+build``
|
|
17
|
+
(see ``src/semver/semver.c:202``).
|
|
18
|
+
|
|
19
|
+
* ``project_settings.config`` must include ``filament_colour`` when plates
|
|
20
|
+
are present. BambuStudio dereferences this without a null check in
|
|
21
|
+
``PartPlateList::load_from_3mf_structure`` (PartPlate.cpp:6544), causing
|
|
22
|
+
a SIGSEGV crash if it is missing.
|
|
23
|
+
|
|
24
|
+
* ``printer_settings_id`` and ``filament_settings_id`` must reference known
|
|
25
|
+
system preset names (e.g. "Bambu Lab P1P 0.4 nozzle"), otherwise a
|
|
26
|
+
"Customized Preset" warning dialog appears.
|
|
27
|
+
|
|
28
|
+
* The BambuStudio CLI (``--info``, ``--slice``) needs complete settings in
|
|
29
|
+
``project_settings.config``. It segfaults on a file that holds only preset
|
|
30
|
+
names. :mod:`bambu3mf.presets` expands the names from the system presets
|
|
31
|
+
of an installed BambuStudio.
|
|
32
|
+
|
|
33
|
+
* BambuStudio assigns objects to plates by **spatial intersection**, not by
|
|
34
|
+
the plate→object mapping in ``model_settings.config``. Objects must be
|
|
35
|
+
physically positioned within their target plate's coordinate region.
|
|
36
|
+
See :mod:`bambu3mf.plate` for the grid layout algorithm.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
import re
|
|
40
|
+
import warnings
|
|
41
|
+
import zipfile
|
|
42
|
+
from xml.sax.saxutils import escape
|
|
43
|
+
|
|
44
|
+
import lib3mf
|
|
45
|
+
|
|
46
|
+
from bambu3mf.config_writer import generate_project_config, generate_project_settings
|
|
47
|
+
from bambu3mf.plate import Plate
|
|
48
|
+
from bambu3mf.presets import PresetLibrary, PresetNotFound, find_profiles_dir
|
|
49
|
+
|
|
50
|
+
BAMBU_NAMESPACE = 'xmlns:BambuStudio="http://schemas.bambulab.com/package/2021"'
|
|
51
|
+
BAMBU_3MF_VERSION = "1"
|
|
52
|
+
DEFAULT_BED_SIZE = (256, 256)
|
|
53
|
+
|
|
54
|
+
BAMBU_APPLICATION = "BambuStudio-02.05.00.66"
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class BambuProject:
|
|
58
|
+
"""A 3MF project that can be opened in BambuStudio.
|
|
59
|
+
|
|
60
|
+
Args:
|
|
61
|
+
bed_size: Print bed dimensions as (width, height) in mm.
|
|
62
|
+
Defaults to the ``printable_area`` of the printer preset. If
|
|
63
|
+
the preset is not available, defaults to (256, 256) for P1/X1
|
|
64
|
+
series printers.
|
|
65
|
+
app_version: Override the Application metadata string.
|
|
66
|
+
Must match the target BambuStudio version to avoid warnings.
|
|
67
|
+
description: Optional 3MF Description metadata text.
|
|
68
|
+
May contain HTML-formatted content; it is XML-escaped before
|
|
69
|
+
being stored in ``3D/3dmodel.model``.
|
|
70
|
+
printer_settings_id: System preset name for the printer,
|
|
71
|
+
e.g. ``"Bambu Lab P1P 0.4 nozzle"``. Must match a preset
|
|
72
|
+
known to BambuStudio to avoid the "Customized Preset" dialog.
|
|
73
|
+
filaments: List of filament dicts, each with optional keys:
|
|
74
|
+
``settings_id``, ``colour`` (hex), ``type``, ``diameter``.
|
|
75
|
+
Determines the filament slots available for extruder assignment.
|
|
76
|
+
filament_settings_id: Legacy shorthand — list of preset name strings.
|
|
77
|
+
Converted to filaments dicts internally. Ignored if ``filaments``
|
|
78
|
+
is also provided.
|
|
79
|
+
profiles_dir: BambuStudio profile folder (``resources/profiles``).
|
|
80
|
+
Defaults to the folder of an installed BambuStudio. When
|
|
81
|
+
``printer_settings_id`` is set and the folder has the presets,
|
|
82
|
+
``save`` writes the complete settings that the BambuStudio CLI
|
|
83
|
+
needs. Otherwise it writes only the preset names, which the
|
|
84
|
+
GUI can open and the CLI cannot.
|
|
85
|
+
"""
|
|
86
|
+
|
|
87
|
+
def __init__(self, *, bed_size=None, app_version=None,
|
|
88
|
+
description=None, printer_settings_id="", print_settings_id="",
|
|
89
|
+
filament_settings_id=None, filaments=None, profiles_dir=None):
|
|
90
|
+
self.app_version = app_version or BAMBU_APPLICATION
|
|
91
|
+
self.description = description
|
|
92
|
+
self.printer_settings_id = printer_settings_id
|
|
93
|
+
self.print_settings_id = print_settings_id
|
|
94
|
+
if filaments:
|
|
95
|
+
self.filaments = filaments
|
|
96
|
+
self.filament_settings_id = filament_settings_id
|
|
97
|
+
elif filament_settings_id:
|
|
98
|
+
self.filaments = [{"settings_id": s} for s in filament_settings_id]
|
|
99
|
+
self.filament_settings_id = filament_settings_id
|
|
100
|
+
else:
|
|
101
|
+
self.filaments = None
|
|
102
|
+
self.filament_settings_id = None
|
|
103
|
+
self.profiles_dir = profiles_dir
|
|
104
|
+
self.bed_size = bed_size or self._preset_bed_size() or DEFAULT_BED_SIZE
|
|
105
|
+
self.plates = []
|
|
106
|
+
self._wrapper = lib3mf.Wrapper()
|
|
107
|
+
self._model = self._wrapper.CreateModel()
|
|
108
|
+
|
|
109
|
+
def add_plate(self, *, name=None):
|
|
110
|
+
"""Create a new plate and return it.
|
|
111
|
+
|
|
112
|
+
Plates are 1-indexed. Each plate occupies a distinct spatial region
|
|
113
|
+
so BambuStudio can assign objects by intersection.
|
|
114
|
+
"""
|
|
115
|
+
plate_id = len(self.plates) + 1
|
|
116
|
+
plate = Plate(plate_id, name=name, project=self)
|
|
117
|
+
self.plates.append(plate)
|
|
118
|
+
return plate
|
|
119
|
+
|
|
120
|
+
def save(self, path):
|
|
121
|
+
"""Write the project to a 3MF file at *path*.
|
|
122
|
+
|
|
123
|
+
The save process:
|
|
124
|
+
1. lib3mf writes the base 3MF (geometry, build items).
|
|
125
|
+
2. BambuStudio namespace + metadata are injected into the model XML.
|
|
126
|
+
3. ``project_settings.config`` (JSON) is appended with printer/filament config.
|
|
127
|
+
4. ``model_settings.config`` (XML) is appended with per-object metadata
|
|
128
|
+
and plate layout (only when plates exist).
|
|
129
|
+
"""
|
|
130
|
+
for plate in self.plates:
|
|
131
|
+
plate._apply_plate_offsets()
|
|
132
|
+
writer = self._model.QueryWriter("3mf")
|
|
133
|
+
writer.WriteToFile(path)
|
|
134
|
+
self._inject_bambu_metadata(path)
|
|
135
|
+
self._inject_project_settings(path)
|
|
136
|
+
if self.plates:
|
|
137
|
+
self._inject_model_config(path)
|
|
138
|
+
|
|
139
|
+
def _inject_bambu_metadata(self, path):
|
|
140
|
+
"""Rewrite the model XML to add BambuStudio namespace and metadata.
|
|
141
|
+
|
|
142
|
+
Adds the BambuStudio XML namespace to ``<model>`` and inserts
|
|
143
|
+
``BambuStudio:3mfVersion`` and ``Application`` metadata elements
|
|
144
|
+
before ``<resources>``. This is done via regex substitution on the
|
|
145
|
+
XML text because lib3mf has no API for custom namespaces.
|
|
146
|
+
"""
|
|
147
|
+
metadata_lines = [
|
|
148
|
+
f'\t<metadata name="BambuStudio:3mfVersion">{escape(BAMBU_3MF_VERSION)}</metadata>',
|
|
149
|
+
f'\t<metadata name="Application">{escape(self.app_version)}</metadata>',
|
|
150
|
+
]
|
|
151
|
+
if self.description is not None:
|
|
152
|
+
metadata_lines.append(
|
|
153
|
+
f'\t<metadata name="Description">{escape(self.description)}</metadata>'
|
|
154
|
+
)
|
|
155
|
+
metadata_xml = "\n".join(metadata_lines) + "\n"
|
|
156
|
+
with zipfile.ZipFile(path, "r") as zin:
|
|
157
|
+
names = zin.namelist()
|
|
158
|
+
contents = {}
|
|
159
|
+
for name in names:
|
|
160
|
+
data = zin.read(name)
|
|
161
|
+
if name == "3D/3dmodel.model":
|
|
162
|
+
text = data.decode("utf-8")
|
|
163
|
+
text = re.sub(
|
|
164
|
+
r"(<model\b)",
|
|
165
|
+
rf"\1 {BAMBU_NAMESPACE}",
|
|
166
|
+
text,
|
|
167
|
+
count=1,
|
|
168
|
+
)
|
|
169
|
+
text = re.sub(
|
|
170
|
+
r"(<resources)",
|
|
171
|
+
metadata_xml + r"\1",
|
|
172
|
+
text,
|
|
173
|
+
count=1,
|
|
174
|
+
)
|
|
175
|
+
data = text.encode("utf-8")
|
|
176
|
+
contents[name] = data
|
|
177
|
+
|
|
178
|
+
with zipfile.ZipFile(path, "w", zipfile.ZIP_DEFLATED) as zout:
|
|
179
|
+
for name in names:
|
|
180
|
+
zout.writestr(name, contents[name])
|
|
181
|
+
|
|
182
|
+
def _inject_project_settings(self, path):
|
|
183
|
+
"""Append ``Metadata/project_settings.config`` (JSON) to the archive."""
|
|
184
|
+
settings_json = generate_project_settings(
|
|
185
|
+
bed_size=self.bed_size,
|
|
186
|
+
printer_settings_id=self.printer_settings_id,
|
|
187
|
+
print_settings_id=self.print_settings_id,
|
|
188
|
+
filaments=self.filaments,
|
|
189
|
+
preset_settings=self._preset_settings(),
|
|
190
|
+
)
|
|
191
|
+
with zipfile.ZipFile(path, "a", zipfile.ZIP_DEFLATED) as z:
|
|
192
|
+
z.writestr("Metadata/project_settings.config", settings_json)
|
|
193
|
+
|
|
194
|
+
def _preset_library(self):
|
|
195
|
+
"""Return the presets for the printer of this project, or ``None``."""
|
|
196
|
+
profiles_dir = self.profiles_dir or find_profiles_dir()
|
|
197
|
+
if not self.printer_settings_id or profiles_dir is None:
|
|
198
|
+
return None
|
|
199
|
+
return PresetLibrary(profiles_dir)
|
|
200
|
+
|
|
201
|
+
def _preset_bed_size(self):
|
|
202
|
+
"""Return the bed size of the printer preset, or ``None``.
|
|
203
|
+
|
|
204
|
+
``printable_area`` is a list of ``"XxY"`` corner points.
|
|
205
|
+
"""
|
|
206
|
+
library = self._preset_library()
|
|
207
|
+
if library is None:
|
|
208
|
+
return None
|
|
209
|
+
try:
|
|
210
|
+
machine = library.resolve("machine", self.printer_settings_id)
|
|
211
|
+
except PresetNotFound:
|
|
212
|
+
return None # save() gives the warning
|
|
213
|
+
corners = [
|
|
214
|
+
[float(n) for n in corner.split("x")]
|
|
215
|
+
for corner in machine["printable_area"]
|
|
216
|
+
]
|
|
217
|
+
return tuple(
|
|
218
|
+
int(size) if size.is_integer() else size
|
|
219
|
+
for size in (max(axis) - min(axis) for axis in zip(*corners))
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
def _preset_settings(self):
|
|
223
|
+
"""Return the complete settings of the named presets, or ``None``."""
|
|
224
|
+
library = self._preset_library()
|
|
225
|
+
if library is None:
|
|
226
|
+
return None
|
|
227
|
+
try:
|
|
228
|
+
return library.project_settings(
|
|
229
|
+
self.printer_settings_id,
|
|
230
|
+
self.print_settings_id,
|
|
231
|
+
[f.get("settings_id") for f in self.filaments or []],
|
|
232
|
+
)
|
|
233
|
+
except PresetNotFound as error:
|
|
234
|
+
warnings.warn(
|
|
235
|
+
f"{error.args[0]}. The file has only preset names, "
|
|
236
|
+
"so the BambuStudio CLI cannot load it.",
|
|
237
|
+
stacklevel=3,
|
|
238
|
+
)
|
|
239
|
+
return None
|
|
240
|
+
|
|
241
|
+
def _inject_model_config(self, path):
|
|
242
|
+
"""Append ``Metadata/model_settings.config`` (XML) to the archive."""
|
|
243
|
+
config_xml = generate_project_config(self.plates)
|
|
244
|
+
with zipfile.ZipFile(path, "a", zipfile.ZIP_DEFLATED) as z:
|
|
245
|
+
z.writestr("Metadata/model_settings.config", config_xml)
|
bambu3mf/stl_loader.py
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"""Low-level STL loading into a lib3mf model with positioning.
|
|
2
|
+
|
|
3
|
+
Handles reading STL files, computing bounding boxes, setting mesh names,
|
|
4
|
+
and positioning objects via build-item transforms. The transform includes
|
|
5
|
+
both the object's position on the plate and the plate's offset in the
|
|
6
|
+
multi-plate grid layout.
|
|
7
|
+
|
|
8
|
+
The lib3mf Transform is a 4x3 matrix stored as Fields[4][3]:
|
|
9
|
+
Fields[0..2] = 3x3 rotation/scale (identity for no rotation)
|
|
10
|
+
Fields[3] = translation (x, y, z)
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
|
|
15
|
+
import lib3mf
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def load_stl(model, path, *, bed_size=(256, 256), position=None):
|
|
19
|
+
"""Load an STL file into a lib3mf model, position on bed, return mesh info.
|
|
20
|
+
|
|
21
|
+
The build item is initially positioned with bed-centering only (no plate
|
|
22
|
+
offset). Plate grid offsets are applied later by
|
|
23
|
+
:meth:`Plate._apply_plate_offsets` at save time.
|
|
24
|
+
|
|
25
|
+
The object is moved in Z so that its lowest point is on the bed. An STL
|
|
26
|
+
file can start above or below Z=0, and BambuStudio does not slice a plate
|
|
27
|
+
with an object that floats above the bed.
|
|
28
|
+
|
|
29
|
+
Args:
|
|
30
|
+
model: A lib3mf Model instance (shared across the project).
|
|
31
|
+
path: Path to the STL file.
|
|
32
|
+
bed_size: ``(width, height)`` of the print bed in mm.
|
|
33
|
+
position: ``(x, y)`` for placing the object's bounding-box min corner
|
|
34
|
+
on the bed. If None, auto-centers on the bed.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
Dict with keys: ``resource_id`` (int), ``vertex_count`` (int),
|
|
38
|
+
``triangle_count`` (int), ``bounding_box`` (dict with min/max x/y/z),
|
|
39
|
+
``center_offset`` (tuple of tx, ty, tz that puts the object on the bed).
|
|
40
|
+
|
|
41
|
+
Raises:
|
|
42
|
+
FileNotFoundError: If the STL file does not exist.
|
|
43
|
+
ValueError: If the object at the given position exceeds the bed bounds.
|
|
44
|
+
"""
|
|
45
|
+
if not Path(path).exists():
|
|
46
|
+
raise FileNotFoundError(f"STL file not found: {path}")
|
|
47
|
+
|
|
48
|
+
reader = model.QueryReader("stl")
|
|
49
|
+
reader.ReadFromFile(str(path))
|
|
50
|
+
|
|
51
|
+
mesh = _get_last_mesh(model)
|
|
52
|
+
mesh.SetName(Path(path).stem)
|
|
53
|
+
bb = _bounding_box(mesh)
|
|
54
|
+
|
|
55
|
+
obj_w = bb["max_x"] - bb["min_x"]
|
|
56
|
+
obj_h = bb["max_y"] - bb["min_y"]
|
|
57
|
+
|
|
58
|
+
if position is not None:
|
|
59
|
+
placed_min_x, placed_min_y = position
|
|
60
|
+
placed_max_x = placed_min_x + obj_w
|
|
61
|
+
placed_max_y = placed_min_y + obj_h
|
|
62
|
+
if (placed_min_x < 0 or placed_min_y < 0
|
|
63
|
+
or placed_max_x > bed_size[0] or placed_max_y > bed_size[1]):
|
|
64
|
+
bi = _get_last_build_item(model)
|
|
65
|
+
model.RemoveBuildItem(bi)
|
|
66
|
+
model.RemoveResource(mesh)
|
|
67
|
+
raise ValueError(
|
|
68
|
+
f"Object ({obj_w:.1f}x{obj_h:.1f}mm) at position "
|
|
69
|
+
f"({position[0]}, {position[1]}) exceeds bed size "
|
|
70
|
+
f"({bed_size[0]}x{bed_size[1]}mm). "
|
|
71
|
+
f"Object bounds: ({placed_min_x}, {placed_min_y}) to "
|
|
72
|
+
f"({placed_max_x:.1f}, {placed_max_y:.1f})"
|
|
73
|
+
)
|
|
74
|
+
tx, ty = position[0] - bb["min_x"], position[1] - bb["min_y"]
|
|
75
|
+
else:
|
|
76
|
+
cx = (bb["min_x"] + bb["max_x"]) / 2
|
|
77
|
+
cy = (bb["min_y"] + bb["max_y"]) / 2
|
|
78
|
+
tx = bed_size[0] / 2 - cx
|
|
79
|
+
ty = bed_size[1] / 2 - cy
|
|
80
|
+
|
|
81
|
+
tz = -bb["min_z"]
|
|
82
|
+
bi = _get_last_build_item(model)
|
|
83
|
+
bi.SetObjectTransform(_translation(tx, ty, tz))
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
"resource_id": mesh.GetResourceID(),
|
|
87
|
+
"vertex_count": mesh.GetVertexCount(),
|
|
88
|
+
"triangle_count": mesh.GetTriangleCount(),
|
|
89
|
+
"bounding_box": bb,
|
|
90
|
+
"center_offset": (tx, ty, tz),
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
def _get_last_mesh(model):
|
|
95
|
+
"""Return the most recently added mesh object in the model."""
|
|
96
|
+
it = model.GetMeshObjects()
|
|
97
|
+
mesh = None
|
|
98
|
+
while it.MoveNext():
|
|
99
|
+
mesh = it.GetCurrentMeshObject()
|
|
100
|
+
return mesh
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def _get_last_build_item(model):
|
|
104
|
+
"""Return the most recently added build item in the model."""
|
|
105
|
+
it = model.GetBuildItems()
|
|
106
|
+
bi = None
|
|
107
|
+
while it.MoveNext():
|
|
108
|
+
bi = it.GetCurrent()
|
|
109
|
+
return bi
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _bounding_box(mesh):
|
|
113
|
+
"""Compute axis-aligned bounding box from mesh vertices."""
|
|
114
|
+
verts = mesh.GetVertices()
|
|
115
|
+
xs = [v.Coordinates[0] for v in verts]
|
|
116
|
+
ys = [v.Coordinates[1] for v in verts]
|
|
117
|
+
zs = [v.Coordinates[2] for v in verts]
|
|
118
|
+
return {
|
|
119
|
+
"min_x": min(xs), "max_x": max(xs),
|
|
120
|
+
"min_y": min(ys), "max_y": max(ys),
|
|
121
|
+
"min_z": min(zs), "max_z": max(zs),
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def load_stl_as_mesh(model, path):
|
|
126
|
+
"""Load an STL into the model as a mesh object without a build item.
|
|
127
|
+
|
|
128
|
+
Used for component parts that will be grouped into a ComponentsObject.
|
|
129
|
+
The auto-created build item is removed, leaving just the mesh resource.
|
|
130
|
+
|
|
131
|
+
Returns:
|
|
132
|
+
Dict with ``resource_id``, ``vertex_count``, ``triangle_count``,
|
|
133
|
+
``bounding_box``, and ``mesh`` (the lib3mf mesh object).
|
|
134
|
+
"""
|
|
135
|
+
if not Path(path).exists():
|
|
136
|
+
raise FileNotFoundError(f"STL file not found: {path}")
|
|
137
|
+
|
|
138
|
+
reader = model.QueryReader("stl")
|
|
139
|
+
reader.ReadFromFile(str(path))
|
|
140
|
+
|
|
141
|
+
mesh = _get_last_mesh(model)
|
|
142
|
+
mesh.SetName(Path(path).stem)
|
|
143
|
+
|
|
144
|
+
# Remove the auto-created build item — we'll add a component instead
|
|
145
|
+
bi = _get_last_build_item(model)
|
|
146
|
+
model.RemoveBuildItem(bi)
|
|
147
|
+
|
|
148
|
+
bb = _bounding_box(mesh)
|
|
149
|
+
return {
|
|
150
|
+
"resource_id": mesh.GetResourceID(),
|
|
151
|
+
"vertex_count": mesh.GetVertexCount(),
|
|
152
|
+
"triangle_count": mesh.GetTriangleCount(),
|
|
153
|
+
"bounding_box": bb,
|
|
154
|
+
"mesh": mesh,
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def create_component_group(model, meshes, *, bed_size=(256, 256),
|
|
159
|
+
position=None):
|
|
160
|
+
"""Group multiple mesh objects into a single ComponentsObject with one build item.
|
|
161
|
+
|
|
162
|
+
The build item is initially positioned with bed-centering only (no plate
|
|
163
|
+
offset). Call :func:`update_build_item_plate_offset` after all plates are
|
|
164
|
+
created to apply the final plate grid offset.
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
model: A lib3mf Model instance.
|
|
168
|
+
meshes: List of lib3mf mesh objects to group.
|
|
169
|
+
bed_size: ``(width, height)`` of the print bed in mm.
|
|
170
|
+
position: ``(x, y)`` for the group's bounding-box min corner.
|
|
171
|
+
If None, auto-centers on the bed.
|
|
172
|
+
|
|
173
|
+
Returns:
|
|
174
|
+
Dict with ``resource_id`` (of the component object) and
|
|
175
|
+
``center_offset`` ``(tx, ty, tz)`` that puts the group on the bed.
|
|
176
|
+
The lowest point of the group is at Z=0.
|
|
177
|
+
"""
|
|
178
|
+
identity = _identity_transform()
|
|
179
|
+
comp_obj = model.AddComponentsObject()
|
|
180
|
+
for mesh in meshes:
|
|
181
|
+
comp_obj.AddComponent(mesh, identity)
|
|
182
|
+
|
|
183
|
+
# Compute combined bounding box
|
|
184
|
+
all_bbs = [_bounding_box(m) for m in meshes]
|
|
185
|
+
combined_bb = {
|
|
186
|
+
"min_x": min(b["min_x"] for b in all_bbs),
|
|
187
|
+
"max_x": max(b["max_x"] for b in all_bbs),
|
|
188
|
+
"min_y": min(b["min_y"] for b in all_bbs),
|
|
189
|
+
"max_y": max(b["max_y"] for b in all_bbs),
|
|
190
|
+
"min_z": min(b["min_z"] for b in all_bbs),
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if position is not None:
|
|
194
|
+
tx = position[0] - combined_bb["min_x"]
|
|
195
|
+
ty = position[1] - combined_bb["min_y"]
|
|
196
|
+
else:
|
|
197
|
+
cx = (combined_bb["min_x"] + combined_bb["max_x"]) / 2
|
|
198
|
+
cy = (combined_bb["min_y"] + combined_bb["max_y"]) / 2
|
|
199
|
+
tx = bed_size[0] / 2 - cx
|
|
200
|
+
ty = bed_size[1] / 2 - cy
|
|
201
|
+
|
|
202
|
+
tz = -combined_bb["min_z"]
|
|
203
|
+
model.AddBuildItem(comp_obj, _translation(tx, ty, tz))
|
|
204
|
+
|
|
205
|
+
return {
|
|
206
|
+
"resource_id": comp_obj.GetResourceID(),
|
|
207
|
+
"center_offset": (tx, ty, tz),
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def update_build_item_plate_offset(model, resource_id, center_offset,
|
|
212
|
+
plate_offset_x, plate_offset_y):
|
|
213
|
+
"""Update a build item's transform to include the final plate grid offset.
|
|
214
|
+
|
|
215
|
+
Called at save time after all plates are created and grid positions are known.
|
|
216
|
+
"""
|
|
217
|
+
it = model.GetBuildItems()
|
|
218
|
+
while it.MoveNext():
|
|
219
|
+
bi = it.GetCurrent()
|
|
220
|
+
obj = bi.GetObjectResource()
|
|
221
|
+
if obj.GetResourceID() == resource_id:
|
|
222
|
+
tx, ty, tz = center_offset
|
|
223
|
+
bi.SetObjectTransform(
|
|
224
|
+
_translation(tx + plate_offset_x, ty + plate_offset_y, tz)
|
|
225
|
+
)
|
|
226
|
+
return
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _identity_transform():
|
|
230
|
+
"""Create a lib3mf Transform initialized to the identity matrix."""
|
|
231
|
+
t = lib3mf.Transform()
|
|
232
|
+
t.Fields[0][0] = 1.0
|
|
233
|
+
t.Fields[1][1] = 1.0
|
|
234
|
+
t.Fields[2][2] = 1.0
|
|
235
|
+
return t
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
def _translation(tx, ty, tz):
|
|
239
|
+
"""Create a lib3mf Transform that only translates."""
|
|
240
|
+
t = _identity_transform()
|
|
241
|
+
t.Fields[3][0] = tx
|
|
242
|
+
t.Fields[3][1] = ty
|
|
243
|
+
t.Fields[3][2] = tz
|
|
244
|
+
return t
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bambu3mf
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python library for creating Bambu Studio 3MF files
|
|
5
|
+
Author: Gavin Stark
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/gstark/bambu3mf
|
|
8
|
+
Project-URL: Source, https://github.com/gstark/bambu3mf
|
|
9
|
+
Project-URL: Issues, https://github.com/gstark/bambu3mf/issues
|
|
10
|
+
Keywords: 3mf,bambu-studio,bambu-lab,3d-printing,slicer
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Manufacturing
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
16
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Multimedia :: Graphics :: 3D Modeling
|
|
25
|
+
Requires-Python: >=3.10
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: lib3mf
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# bambu3mf
|
|
34
|
+
|
|
35
|
+
Python library for creating BambuStudio-compatible 3MF project files. Supports multi-plate layouts, per-object extruder assignment, and printer/filament preset configuration.
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install bambu3mf
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Requires Python 3.10+ and [lib3mf](https://github.com/3MFConsortium/lib3mf).
|
|
44
|
+
|
|
45
|
+
lib3mf publishes wheels only for Linux x86_64, macOS, and Windows x86_64. On other platforms, such as Linux on ARM, `pip install` fails.
|
|
46
|
+
|
|
47
|
+
## Quick Start
|
|
48
|
+
|
|
49
|
+
```python
|
|
50
|
+
from bambu3mf import BambuProject
|
|
51
|
+
|
|
52
|
+
project = BambuProject(
|
|
53
|
+
printer_settings_id="Bambu Lab P1P 0.4 nozzle",
|
|
54
|
+
filaments=[
|
|
55
|
+
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#FF0000"},
|
|
56
|
+
{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#0000FF"},
|
|
57
|
+
],
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
plate = project.add_plate(name="My Plate")
|
|
61
|
+
plate.add_stl("body.stl", extruder=1)
|
|
62
|
+
plate.add_stl("accent.stl", position=(150, 100), extruder=2)
|
|
63
|
+
|
|
64
|
+
project.save("output.3mf")
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Open `output.3mf` in BambuStudio and it will load with correct plate layout, filament colors, and printer preset -- ready to slice.
|
|
68
|
+
|
|
69
|
+
## Examples
|
|
70
|
+
|
|
71
|
+
### Single Object, Auto-Centered
|
|
72
|
+
|
|
73
|
+
```python
|
|
74
|
+
from bambu3mf import BambuProject
|
|
75
|
+
|
|
76
|
+
project = BambuProject()
|
|
77
|
+
plate = project.add_plate()
|
|
78
|
+
plate.add_stl("model.stl") # centered on bed automatically
|
|
79
|
+
project.save("simple.3mf")
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Multi-Plate Project
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
from bambu3mf import BambuProject
|
|
86
|
+
|
|
87
|
+
project = BambuProject(
|
|
88
|
+
printer_settings_id="Bambu Lab X1 Carbon 0.4 nozzle",
|
|
89
|
+
filaments=[{"settings_id": "Bambu PLA Basic @BBL X1C", "colour": "#FFFFFF"}],
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
p1 = project.add_plate(name="Base Parts")
|
|
93
|
+
p1.add_stl("base_left.stl", position=(10, 10))
|
|
94
|
+
p1.add_stl("base_right.stl", position=(140, 10))
|
|
95
|
+
|
|
96
|
+
p2 = project.add_plate(name="Top Parts")
|
|
97
|
+
p2.add_stl("top.stl")
|
|
98
|
+
|
|
99
|
+
project.save("multi_plate.3mf")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Plates are arranged in a grid layout matching BambuStudio's internal algorithm. Objects are assigned to plates by spatial position.
|
|
103
|
+
|
|
104
|
+
### Multi-Color Print
|
|
105
|
+
|
|
106
|
+
```python
|
|
107
|
+
from bambu3mf import BambuProject
|
|
108
|
+
|
|
109
|
+
project = BambuProject(
|
|
110
|
+
printer_settings_id="Bambu Lab P1S 0.4 nozzle",
|
|
111
|
+
filaments=[
|
|
112
|
+
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#000000", "type": "PLA"},
|
|
113
|
+
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#FF5733", "type": "PLA"},
|
|
114
|
+
{"settings_id": "Bambu PLA Basic @BBL P1S", "colour": "#FFFFFF", "type": "PLA"},
|
|
115
|
+
],
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
plate = project.add_plate()
|
|
119
|
+
plate.add_stl("frame.stl", extruder=1) # black
|
|
120
|
+
plate.add_stl("logo.stl", position=(80, 80), extruder=2) # orange
|
|
121
|
+
plate.add_stl("text.stl", position=(80, 120), extruder=3) # white
|
|
122
|
+
|
|
123
|
+
project.save("multicolor.3mf")
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Custom Bed Size (A1 Mini)
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from bambu3mf import BambuProject
|
|
130
|
+
|
|
131
|
+
project = BambuProject(
|
|
132
|
+
bed_size=(180, 180),
|
|
133
|
+
printer_settings_id="Bambu Lab A1 mini 0.4 nozzle",
|
|
134
|
+
)
|
|
135
|
+
plate = project.add_plate()
|
|
136
|
+
plate.add_stl("small_part.stl")
|
|
137
|
+
project.save("a1_mini.3mf")
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Description Metadata
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
from bambu3mf import BambuProject
|
|
144
|
+
|
|
145
|
+
project = BambuProject(
|
|
146
|
+
description="<p>Print-in-place gearbox with 0.2mm clearance.</p>",
|
|
147
|
+
)
|
|
148
|
+
plate = project.add_plate(name="Main")
|
|
149
|
+
plate.add_stl("gearbox.stl")
|
|
150
|
+
project.save("described.3mf")
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
`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.
|
|
154
|
+
|
|
155
|
+
### Slicing with the BambuStudio CLI
|
|
156
|
+
|
|
157
|
+
The BambuStudio CLI needs complete settings in the file. It segfaults on a file that holds only preset names.
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
```python
|
|
162
|
+
project = BambuProject(
|
|
163
|
+
printer_settings_id="Bambu Lab P1P 0.4 nozzle",
|
|
164
|
+
print_settings_id="0.20mm Standard @BBL P1P",
|
|
165
|
+
filaments=[{"settings_id": "Bambu PLA Basic @BBL P1P", "colour": "#FF0000"}],
|
|
166
|
+
)
|
|
167
|
+
project.add_plate().add_stl("part.stl")
|
|
168
|
+
project.save("part.3mf")
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```bash
|
|
172
|
+
BambuStudio --slice 0 --outputdir "$PWD/out" --export-3mf sliced.3mf part.3mf
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
- `save` finds the profile folder on macOS and Windows. On other systems, pass `profiles_dir` (the `resources/profiles` folder of BambuStudio).
|
|
176
|
+
- If no profile folder is found, `save` writes only the preset names. The GUI can open that file. The CLI cannot.
|
|
177
|
+
- If a preset name is not in the profile folder, `save` gives a warning and writes only the preset names.
|
|
178
|
+
- `bed_size` defaults to the `printable_area` of the printer preset. If you pass `bed_size`, it must match the printer.
|
|
179
|
+
|
|
180
|
+
## API Reference
|
|
181
|
+
|
|
182
|
+
### `BambuProject`
|
|
183
|
+
|
|
184
|
+
```python
|
|
185
|
+
BambuProject(
|
|
186
|
+
*,
|
|
187
|
+
bed_size=None, # (width, height) in mm (default: from the printer preset, else 256 x 256)
|
|
188
|
+
printer_settings_id="", # BambuStudio printer preset name
|
|
189
|
+
filaments=None, # list of filament dicts (see below)
|
|
190
|
+
app_version=None, # override Application metadata
|
|
191
|
+
description=None, # optional 3MF Description metadata (HTML text is XML-escaped)
|
|
192
|
+
profiles_dir=None, # BambuStudio profile folder (default: the installed app)
|
|
193
|
+
)
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
**Filament dicts** accept these keys:
|
|
197
|
+
|
|
198
|
+
| Key | Default | Description |
|
|
199
|
+
|---|---|---|
|
|
200
|
+
| `settings_id` | `""` | BambuStudio filament preset name |
|
|
201
|
+
| `colour` | `"#00AE42"` | Hex color shown in slicer UI |
|
|
202
|
+
| `type` | `"PLA"` | Material type |
|
|
203
|
+
| `diameter` | `"1.75"` | Filament diameter in mm |
|
|
204
|
+
|
|
205
|
+
**Methods:**
|
|
206
|
+
|
|
207
|
+
- `add_plate(*, name=None)` -- Create a new plate. Returns a `Plate`. Plates are 1-indexed.
|
|
208
|
+
- `save(path)` -- Write the 3MF file.
|
|
209
|
+
|
|
210
|
+
### `Plate`
|
|
211
|
+
|
|
212
|
+
Created via `project.add_plate()`. Do not instantiate directly.
|
|
213
|
+
|
|
214
|
+
**Methods:**
|
|
215
|
+
|
|
216
|
+
- `add_stl(path, *, position=None, extruder=1)` -- Load an STL onto this plate.
|
|
217
|
+
- `position`: `(x, y)` in mm for the object's min corner, relative to plate origin. `None` to auto-center.
|
|
218
|
+
- `extruder`: 1-indexed filament slot.
|
|
219
|
+
- Returns a dict with `resource_id`, `vertex_count`, `triangle_count`, `bounding_box`.
|
|
220
|
+
- Raises `FileNotFoundError` if the STL doesn't exist.
|
|
221
|
+
- Raises `ValueError` if the object exceeds bed bounds at the given position.
|
|
222
|
+
|
|
223
|
+
## How It Works
|
|
224
|
+
|
|
225
|
+
The library generates a valid 3MF ZIP archive containing:
|
|
226
|
+
|
|
227
|
+
| File | Format | Purpose |
|
|
228
|
+
|---|---|---|
|
|
229
|
+
| `3D/3dmodel.model` | XML | Mesh geometry with BambuStudio namespace |
|
|
230
|
+
| `Metadata/project_settings.config` | JSON | Printer, filament, and bed configuration |
|
|
231
|
+
| `Metadata/model_settings.config` | XML | Per-object metadata and plate layout |
|
|
232
|
+
|
|
233
|
+
Mesh geometry is handled by [lib3mf](https://github.com/3MFConsortium/lib3mf). BambuStudio-specific metadata (namespace, version, config files) is injected post-write since lib3mf has no API for custom namespaces.
|
|
234
|
+
|
|
235
|
+
**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.
|
|
236
|
+
|
|
237
|
+
## Development
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
pip install -e ".[dev]"
|
|
241
|
+
pytest
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## License
|
|
245
|
+
|
|
246
|
+
See [LICENSE](LICENSE) for details.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
bambu3mf/__init__.py,sha256=QtdugjZRuiQ22CzQrfVOe55vFOgIPd9qHoTcKzZBBoY,969
|
|
2
|
+
bambu3mf/config_writer.py,sha256=2nGLQg-GVDu0kBKeovEJYtB8xdG1LUg0tSXqt42-3p4,5906
|
|
3
|
+
bambu3mf/plate.py,sha256=s5POC_fkLsxPc9Tjf2foF-5l5PAPuspWfM9xOaCCmMs,6028
|
|
4
|
+
bambu3mf/presets.py,sha256=7GshRLkqkHQ1IkxLxpmj0ZLHN9fdVsRHke2n_thOUOg,5789
|
|
5
|
+
bambu3mf/project.py,sha256=ebusM5Nvx3pgUk46fmIoX0yk7yt41AaZZ8GcMm9VT8g,10672
|
|
6
|
+
bambu3mf/stl_loader.py,sha256=SCCz_ggCa8p7Lv0LzI0R4WM7KN-jASvk6dfnBO3nL9g,8385
|
|
7
|
+
bambu3mf-0.1.0.dist-info/licenses/LICENSE,sha256=N3VO6SNIBTgbO6YUU9ATe27Qk57QhouMqkLkjOH1cvE,1068
|
|
8
|
+
bambu3mf-0.1.0.dist-info/METADATA,sha256=km23CamQcHKKNoGE3u14fR6Y6vxJKKOqmjHFcckNau4,8320
|
|
9
|
+
bambu3mf-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
10
|
+
bambu3mf-0.1.0.dist-info/top_level.txt,sha256=fb2F0DVvmvnx1Nr-Y-mCQVAnjW7bw4ptkOrZRdCOnEI,9
|
|
11
|
+
bambu3mf-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Gavin Stark
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
bambu3mf
|