System Name: BambuForge Architecture & Process Engineered With: Gemini 4 Argon Target Domain: Autonomous Parametric B-Rep CAD Generation, Third-Party Mesh Surgery, Multi-Color AMS Segmentation, Per-Zone Structural Slicing & Support-Free 3D Print Verification
BambuForge is a Specification-Driven Design (SDD) agentic framework that bridges natural-language engineering requirements directly to production-ready, multi-plate, multi-color, structurally optimized .3mf and .step files.
Unlike cloud text-to-mesh generators that produce non-manifold, low-precision triangle soups requiring heavy support structures, BambuForge operates as a deterministic local engineering compiler powered by OpenCascade 8.0 (build123d), Trimesh topological surgery, and headless Slicer CLI orchestration:
- Zero-Support Geometric Invariants (
<= 45°): Every feature—from horizontal bores to stackable male locking pins and sub-soil irrigation arches—is mathematically constrained or print-orientation inverted (180°) so the entire project prints withenable_support = 0. - Multi-Color & Multi-Zone B-Rep Boolean Partitioning: Models are partitioned via exact B-Rep boolean algebra (
&,-,+) into watertight sub-assemblies that serve both multi-color AMS aesthetics (up to 6+ filament slots) and localized structural reinforcement. - Automated Per-Part Slicing & Modifier Mesh Injection: The
.3mfpackager embeds per-zonewall_loops,sparse_infill_density,sparse_infill_pattern(gyroid), and native<part subtype="modifier_part">100%solid infill volumes directly intoMetadata/model_settings.config. - Closed-Loop Self-Learning (
self-learning-cad): Dimensional tolerances, slicer quirks, and workflow refinements are captured intolearned-preferences.mdandAGENTS.md, preventing regression across sessions.
flowchart LR
subgraph SpecLayer["1. Specification & Memory Layer"]
AGENTS["AGENTS.md<br/>Hardware Envelope, Tolerances<br/>& Support-Free Invariants"]
PREFS["learned-preferences.md<br/>Calibrated Fit & Slicer Rules"]
end
subgraph SkillLayer["2. Autonomous Skill Execution Layer"]
CAD["Skill: 3d-print-modeling<br/>• build123d B-Rep Synthesis<br/>• PNG-to-SVG Vectorizer (png_to_svg.py)<br/>• Read-Only imports/ Mesh Surgery<br/>• Multi-Zone Boolean Partitioning<br/>• Flush Planar Modular Joints"]
SLICER["Skill: bambu-studio-ai<br/>• 2-Column Multi-Plate .3mf Packager<br/>• 6-Filament Profile Flattener<br/>• Per-Zone Infill & 100% Modifier Injector<br/>• 11-Point Overhang & Manifold Auditor"]
LEARN["Skill: self-learning-cad<br/>• Root-Cause Gap Classification<br/>• /learn Proposal & Rule Promotion"]
end
subgraph OutputLayer["3. Verified Deliverable Package"]
THREEMF["Multi-Plate .3mf Project<br/>• Trays 1..N on 2-Col Grid<br/>• Pre-Assigned AMS Extruders<br/>• 20%/35%/40%/100% Infill Zones"]
STEP["Native B-Rep .step & .stl<br/>• G2/G3 Arc Slicing Ready<br/>• FreeCAD 1.1 Editable"]
DOCS["Visual Documentation<br/>• ASSEMBLY_GUIDE.md<br/>• 3D Cutaway/Exploded PNGs<br/>• Interactive Three.js Viewer"]
end
SpecLayer --> SkillLayer
SkillLayer --> OutputLayer
OutputLayer -.->|"Post-Print / User Feedback"| LEARN
LEARN -.->|"Updates Invariants"| SpecLayer
The root AGENTS.md acts as the single source of truth governing agent behavior:
- Build Volume Enforcement: Default
256 × 256 × 256 mm(Bambu Lab P2S / X1C / P1S / A1), with a250 × 250 × 250 mmsafe single-part envelope. - Nozzle-Multiple Wall Quantization (
0.4 mmNozzle):- Cosmetic / Light:
1.25–1.29 mm(3perimeter walls) - Functional / Watertight:
1.65–1.74 mm(4perimeter walls) - Heavy Structural:
2.50–4.20 mm(6+perimeter walls or3–4walls + Gyroid core)
- Cosmetic / Light:
- Layer-Multiple Z-Steps (
0.20 mmStandard Layer): All horizontal ledges, floor thicknesses (5.0 mm = 25 layers), and sacrificial counterbore bridges (0.20 mm = 1 layer) are integer multiples of the layer height.
-
Overhang Angle Bound: Every downward-facing surface normal
$\mathbf{n} = (n_x, n_y, n_z)$ above the build plate (Z > 0.25 mm) must satisfy:$$\theta_{\text{vertical}} = \arcsin(|n_z|) \le 45^\circ \quad (\text{i.e., } n_z \ge -\frac{\sqrt{2}}{2} \approx -0.7071)$$ -
Bed Contact Edge Treatment (
Z = 0): Fillets on bottom horizontal edges are prohibited (their tangent approaches$90^\circ$ overhang at layer 1–3). Vertical edges are filleted first (edges().filter_by(Axis.Z)), followed by a45°chamfer()(0.8–1.5 mm) on theZ = 0face loop. -
Horizontal Bore Compensation (
Ø > 5.0 mm): Circular horizontal holes> 5 mmare replaced bymake_teardrop_cylinder()(a45°pointed or truncated roof) or an octagonal/diamond cross-section so the crown bridges cleanly. -
Print-Orientation Inversion (
180°Flip for Interlocking Pins): Modules requiring downward-protruding male alignment pins (such as the Stackable Deep-Root Extension Riser) are designed with a flat top rim and exported inverted180°so the flat top rim sits onZ = 0and the 4 locking rods print pointing straight UP (+Z) above a45°conical transition.
-
Context Isolation Rule: In
build123d, opening a nestedwith BuildPart():inside a helper function resets the active builder context. All helper solids (make_profile_band,make_dual_rod_cutter,make_bottom_runoff_arch) are constructed in standaloneBuildPartscopes and combined via explicit boolean operators (+union,-subtraction,&intersection). -
Multi-Zone Watertight Segmentation: A monolithic
Partis partitioned into$K$ non-overlapping B-Rep zones$Z_1, Z_2, \dots, Z_K$ such that:$$\bigcup_{i=1}^{K} Z_i = P_{\text{master}}, \quad \text{Vol}(Z_i \cap Z_j) = 0 ;;\forall i \neq j$$ This guarantees zero coplanar z-fighting in Bambu Studio while allowing each zone$Z_i$ to receive an independent AMS Extruder ID (1..6) AND independent Structural Slicing Parameters (wall_loops,sparse_infill_density,sparse_infill_pattern).
When modifying third-party .3mf or .stl models placed in imports/<folder>/:
-
Read-Only Contract:
imports/is never modified; all derived code and exports are written tomodels/<model-name>/. -
Feature-Preserving Mid-Section Resizing: To change the height of an imported container from
$H_0$ to$H_1$ (delta = H_1 - H_0) without distorting bottom mechanical mounts ($z \in [0, z_{\text{low}}]$ ) or top snap-fit lid rebates ($z \in [z_{\text{high}}, H_0]$ ):- First, split all mesh triangles intersecting the horizontal planes
$z = z_{\text{low}}$ and$z = z_{\text{high}}$ viatrimesh.intersections.slice_faces_plane(). - Apply the continuous piecewise-linear Z-transformation: $$z' = \begin{cases} z, & z \le z_{\text{low}} \[4pt] z_{\text{low}} + (z - z_{\text{low}}),\dfrac{(z_{\text{high}} - z_{\text{low}}) + \Delta H}{z_{\text{high}} - z_{\text{low}}}, & z_{\text{low}} < z < z_{\text{high}} \[8pt] z + \Delta H, & z \ge z_{\text{high}} \end{cases}$$
- This preserves
0.000 mmdimensional error on both the bottom mechanism and the top rebate step.
- First, split all mesh triangles intersecting the horizontal planes
Bambu Studio arranges 256 × 256 mm build plates in a 2-column grid (m_plate_cols = 2) with a 307.2 mm center-to-center stride (256.0 mm bed + 51.2 mm margin). For Plate k (k = 1, 2, ...):
- Plate 1 (
k = 1):(128.0, 128.0, 0.0) - Plate 2 (
k = 2):(435.2, 128.0, 0.0) - Plate 3 (
k = 3):(128.0, -179.2, 0.0) - Plate 4 (
k = 4):(435.2, -179.2, 0.0)
- Slicer profile JSONs use
"inherits"chains (e.g.,Bambu Lab P2S 0.4 nozzle.json$\to$ fdm_bbl_3dp_001_common.json)._flatten_bambu_json()recursively resolves the inheritance tree before invokingbambu-studio --load-settings. - To populate a 6-color AMS palette without triggering array-length mismatch faults in
project_settings.config, 6 flattened filament JSON files are passed via--load-filaments "f1.json;f2.json;...;f6.json".
Inside Metadata/model_settings.config, each <part id="..." subtype="normal_part"> and <part id="..." subtype="modifier_part"> is injected with explicit process metadata:
- Main Wall Panels (
normal_part):wall_loops = 3,sparse_infill_density = 20%,sparse_infill_pattern = gyroid - Horizontal Reinforcing Belts & Rim (
normal_part):wall_loops = 3,sparse_infill_density = 35%,sparse_infill_pattern = gyroid - 4 Corner Trellis Columns (
normal_part):wall_loops = 4,sparse_infill_density = 40%,sparse_infill_pattern = gyroid - Rod & Socket Connection Zones (
modifier_part): Bounding boxes covering the top28 mmBase corner sockets and the top44 mmRiser locking rods + internal root transitions are injected assubtype="modifier_part"withwall_loops = 4,sparse_infill_density = 100%,sparse_infill_pattern = rectilinear(normalized by Bambu Studio to100%solid infill). - Sub-Soil Perforated Irrigation Arch Straws (
normal_part):wall_loops = 3,sparse_infill_density = 100%.
Audits every exported .stl / .3mf mesh against 11 quantitative criteria:
- Triangle count & parser integrity
- Watertight manifold edge verification (
edge_count == 2for all edges) - Positive signed volume & outward normal winding
- Connected component island check
- Printer build volume check (
<= 256 × 256 × 256 mm) - Safe margin check (
<= 250 × 250 × 250 mm) - Build plate seating (
|Z_min| <= 0.05 mm) - First-layer bed contact area (
>= 25.0 mm²) - Aspect ratio stability
- Support-free overhang area (
> 45°from vertical< 5%) - Severe overhang / unbridged ceiling check (
> 60°from vertical< 150 mm²)
generate_assembly_guides.pyrenders multi-panel 3D cutaway and exploded assembly diagrams (previews/*_assembly_guide.png).- Z-Order Rendering Invariant: Matplotlib
Axes3Dsubplots are initialized withcomputed_zorder=False, 3DPoly3DCollectionmeshes are assignedzorder = 1..6, and 2D callout badges (ax.text2D) are assignedzorder = 100, preventing 3D geometry from ever occluding instructional callout text.
- Root-Cause Classification: Categorizes every user adjustment or post-print observation into
tolerance_calibration,support_free_geometry,structural_strength,ergonomics_aesthetics, orworkflow_organization. - Proposal-Driven Persistence (
/learn): Generates a structured diff proposal before modifyingSKILL.mdorAGENTS.md, ensuring only reusable, universal rules (and never one-off model-specific requests or personal chat remarks) are persisted.