Skip to content

armgit / forma

Public Imported from GitHub
0

A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server

17.3 KB
Raw Blame

forma-print: Optional 3D Printing Addon Blueprint

  • Status: Tier 1 Shipped (crates/forma-print, research/, tests/e2e/) — Tier 2/3 Help Wanted
  • Target: Opt-in workspace crate (crates/forma-print, excluded from default-members)
  • Core Impact: 0 bytes on core forma / forma.wasm, 0 tokens on core forma-mcp
  • Design Review: Required before multi-PR implementation (see CONTRIBUTING.md)

[!IMPORTANT] Zero-Bloat Guarantee: crates/forma-print sits in workspace.members but is excluded from default-members (the exact same pattern as forma-server). When not installed/enabled, it adds 0 bytes to core forma / forma-mcp / forma.wasm and 0 tokens to forma-mcp's <800-token schema.


1. 3D Printer Hardware Matrix & Printability Physics

1.1 Built-In Verified Printer Profiles (profiles.rs)

Printer Profile ID Tech Kinematics Build Volume X × Y × Z (mm) Nozzle / XY Res Multi-Material & Special Notes
bambu_a1_mini FDM Bedslinger 180 × 180 × 180 0.2 / 0.4 / 0.6 / 0.8 mm AMS Lite (4 slots); bedslinger Y-inertia favors low-Z
bambu_a1 FDM Bedslinger 256 × 256 × 256 0.2 / 0.4 / 0.6 / 0.8 mm AMS Lite (4 slots)
bambu_p1s FDM CoreXY (enclosed) 256 × 256 × 256 0.2 / 0.4 / 0.6 / 0.8 mm AMS up to 16 slots; front-left cutter exclusion (~18 × 28 mm)
bambu_x1c FDM CoreXY (enclosed) 256 × 256 × 256 0.2 / 0.4 / 0.6 / 0.8 mm Hardened steel, LiDAR, AMS up to 16 slots; ABS/ASA/PA-CF
bambu_h2d_single FDM Dual-Nozzle CoreXY 325 × 320 × 325 0.2–0.8 mm Single-nozzle zone (total physical bed 350 × 320 × 325)
bambu_h2d_dual FDM Dual-Nozzle CoreXY 300 × 320 × 320 0.2–0.8 mm Dual-nozzle overlap zone (dissimilar support interfaces, ~0 purge)
prusa_mk4s FDM Bedslinger 250 × 210 × 220 0.25–0.8 mm (0.4 HF) 360° high-flow cooling (strong overhangs up to ~55°), MMU3 (5 slots)
prusa_core_one FDM CoreXY (enclosed) 250 × 220 × 270 0.25–0.8 mm (0.4 HF) Active chamber temp control, MMU3
prusa_xl FDM CoreXY Toolchanger 360 × 360 × 360 0.25–0.8 mm 1–5 independent toolheads (near-zero purge, TPU+PLA)
voron_24_250/300/350 FDM Flying-Gantry CoreXY 250³ / 300³ / 350³ 0.4 / 0.6 mm Klipper/Moonraker native; ABS/ASA; optional ERCF/BoxTurtle
creality_k1c FDM CoreXY (enclosed) 220 × 220 × 250 0.4 mm hardened CF-ready, Klipper-based
creality_k2_plus FDM CoreXY (enclosed) 350 × 350 × 350 0.4–0.8 mm CFS multi-color (up to 16 slots), actively heated chamber
elegoo_mars_5_ultra MSLA Tilt-Release LCD 153.36 × 77.76 × 165 18 × 18 µm (9K) Tilt-vat; drain holes & suction checks critical
elegoo_saturn_4_ultra MSLA Tilt-Release LCD 218.88 × 122.88 × 220 19 × 24 µm (12K) Tilt-vat; brittle unsupported walls < 1.0 mm
formlabs_form_4 MSLA (LFD) Masked SLA 200 × 125 × 210 50 µm XY Engineering resins; 0.5 mm supported / 1.0 mm unsupported walls
formlabs_fuse_1p SLS Laser Powder Bed 165 × 165 × 300 ~110 µm laser Zero supports; requires powder escape holes & ≥0.5 mm clearance

[!NOTE] Unit Support Already in Core (v0.4.2): Core Forma supports units("mm") / --unit mm (defaulting to metres), emitting unit="millimeter" in .3mf, SI_UNIT(.MILLI.,.METRE.) in .step, millimetre labels in .svg, and metre-scaled .glb. forma-print should read Scene.unit directly and convert coordinates to millimetres for printer DFM checks (defaulting to mm or warning if a meter-scaled model exceeds the build plate).

1.2 Printability Physics & Pure-Rust Detection Math

Constraint FDM (0.4 mm Nozzle) SLA / MSLA Resin SLS (PA12) Detection Algorithm in forma-print
Min Wall Thickness (Screen) ≥ 0.84 mm (2 lines); functional ≥ 1.6 mm ≥ 0.5 mm supported / ≥ 1.0 mm unsupported ≥ 0.7–1.0 mm Inward BVH raycast along -n_f (+ 4 tilted cone rays ±12°) from face centroids; report min + p01 (separates localized chamfer/lip artifacts from true thin walls) with all-positive-face fallback for fine collars.
Overhang Angle (Screen) 45° (n.z < -0.7071; MK4S/X1C ~55°) 30° (n.z < -0.866) None (powder bed) Exclude bed faces (z <= z_min + layer_h); flag downward faces exceeding angle limit (excluding short bridges) and report % area share.
Self-Intersections (Screen) Fatal slicer artifacts / inverted shells Cured internal voids / slicer errors Bad slicing Reuse forma_core::boolean::check_self_intersections (budgeted non-adjacent triangle-pair overlap check) to catch watertight meshes containing interpenetrating shells.
Floating Islands (Z-Minima) Fatal without supports Catastrophic (cured flake tears FEP/LCD) N/A Vertex-adjacency local Z-minima above z_min + spatial::section_z slice-to-slice XY overlap check (new loop with 0 overlap below = floating island).
Bridge Spans Safe ≤ 10–25 mm (PLA/PETG), ≤ 8–12 mm (ABS) Poor (≤ 2–3 mm) Unlimited Horizontal downward planar clusters (n.z < -0.98, z > z_min + layer_h): classify supported vs open boundary edges and span width.
XY Clearances & Shrinkage Tight 0.15 mm, snug 0.20 mm, sliding/PIP 0.30–0.40 mm Tight 0.10 mm, sliding 0.20–0.30 mm ≥ 0.50 mm (powder clearing) forma_core::spatial::clearance(a, b) on scene part pairs; flag fusing gaps < min_clearance or intersections.
Articulated / PIP Travel Rest ≥ 0.30–0.40 mm; full travel > 0; pin axis aligned against layer shear Rest ≥ 0.20–0.30 mm; drain resin traps in knuckles Rest ≥ 0.50 mm for powder escape across joint Stateless revolute/prismatic swept clearance (swing_clear / slide_clear) across exact range endpoints + tolerance overtravel, plus joint-axis orientation check against build Z.
Bed Fit, Adhesion & Tipping Usable XY = bed_xy - 2 × brim_margin (allowing 90° XY swap); elephant's foot 0.15–0.30 mm; warn if contact < 100 mm² or H / width > 4 Usually angled 30–45° on raft Check Z & XY packing envelope Brim-aware sorted-XY bed fit (+ optional informational bambu_a1_mini 180³ mm flag), bed-face area sum, 2D convex hull of bed footprint, and divergence-theorem CoM (com.x, com.y) inside-hull check.
SLA Suction Cups & Traps N/A Vacuum tears layers / trapped liquid resin cracks part; needs ≥2 holes Ø ≥ 3.5 mm Trapped powder; needs ≥2 holes Ø ≥ 5.0 mm Track CW inner hole loops across section_z slices: closed-top downward-open cavity = suction cup; enclosed negative shell = trapped cavity.
AMS / MMU Swap Waste ~0.4–1.5 g purge + ~45–90 s per swap on single-nozzle AMS/MMU Single vat Single bed Count unique mat_id transitions per Z-layer band; estimate purge grams and recommend orientation minimizing color-change layers.

2. Slicers, Multi-Color .3mf Internals & Hardware Standards

2.1 Slicers & Local Printer APIs

  • OrcaSlicer / Bambu Studio: Headless CLI (orca-slicer --slice 0 --load-settings ... --export-3mf out.gcode.3mf model.3mf, --pipe for JSON progress); native .step and Bambu-dialect multi-extruder .3mf.
  • PrusaSlicer: Headless CLI (prusa-slicer --export-gcode --load config.ini --output out.gcode model.3mf); native .step and Metadata/Slic3r_PE_model.config.
  • CuraEngine: Headless C++ CLI engine (CuraEngine slice -j machine.def.json -o out.gcode -l model.stl).
  • MSLA Resin: Chitubox / Lychee (GUI-first) + UVtools open-source CLI for .ctb/.goo/.sl1s inspection.
  • LAN Printer APIs: Klipper / Moonraker (POST /server/files/upload pure-Rust HTTP/1.1 multipart) & OctoPrint (POST /api/files/local). (Bambu Lab LAN FTPS/MQTTS requires LAN-Only + Developer Mode on current firmware.)

2.2 Slicer-Native Multi-Color .3mf Layout (AMS / MMU Pre-Assigned)

model.3mf (ZIP + pure-Rust RFC-1951 Deflate, 5-8x smaller than stored ZIP)
├── [Content_Types].xml
├── _rels/.rels                         # Points to /3D/3dmodel.model + /Metadata/plate_1.png
├── 3D/3dmodel.model                    # unit="millimeter", <basematerials>, <m:colorgroup>, component sub-meshes per mat_id
└── Metadata/
    ├── model_settings.config           # Bambu Studio / OrcaSlicer per-part 1-indexed `extruder` + `modifier_part`
    ├── project_settings.config         # JSON `filament_colour[]` & `filament_type[]` from Forma `mat()`
    ├── plate_1.json                    # Build plate bbox & slot map (plate_2.json... for multi-plate!)
    ├── Slic3r_PE_model.config          # PrusaSlicer XL / MMU3 per-volume `extruder` mapping
    └── plate_1.png                     # 256×256 preview thumbnail via `forma_core::render`

Dragging a forma-print-exported .3mf into Bambu Studio, OrcaSlicer, or PrusaSlicer automatically pre-populates AMS/MMU filament slots with the colors from Forma's mat() calls — and supports tagging parts as subtype="modifier_part" (e.g. local 100% infill around bolt bosses).

2.3 Verified Hardware & Fastener Standards (fasteners.rs)

CNC Kitchen / Voron Heat-Set Insert Table

Spec ID Insert OD × L (mm) CAD Pilot Ø (mm) Blind Depth (mm) Min Boss OD (mm) Lead-in Chamfer
M2 3.2 × 3.0 3.2 4.0 6.4 0.4 mm × 45°
M2.5 3.6 × 4.0 3.6 5.0 7.2 0.4 mm × 45°
M3_voron 5.0 × 4.0 4.0 5.0 8.5 0.5 mm × 45°
M3_std 4.6 × 5.7 4.0 6.7 8.5 0.5 mm × 45°
M4 6.3 × 8.1 5.6 9.1 11.0 0.6 mm × 45°
M5 7.5 × 9.5 6.4 10.5 13.0 0.7 mm × 45°

Published Metric Fastener Reference Tables (M2–M12)

  • ISO 273:1979 clearance holes (close / medium / coarse series) for bolts and screws.
  • ISO 4762 socket-head cap screw head dimensions (dk_max, k_max).
  • DIN 974-1 counterbore diameters for ISO 4762 heads (M3–M12).
  • No-guess rule: Every table lookup carries its standard citation; any size absent from the table is reported as unchecked rather than interpolated. For heat-set inserts placed in through-holes without an explicit blind depth, check the part's thickness along the hole axis so an insert deeper than the plate cannot silently pass.

3. Zero-Bloat Addon Architecture

flowchart LR
    Core["forma-core + forma-lang\n(unchanged core crates)"] --> CLI["forma (~1.7 MB)\nGit-style dispatch: forma print ..."]
    Core --> MCP["forma-mcp (<800 tok)\n0 extra tokens"]
    Core --> WASM["forma-3d (~0.8 MB WASM)\n0 extra bytes"]
    Core -. "opt-in crate\n(excluded from default-members)" .-> Print["forma-print (standalone binary)\nCLI + --mcp (~380 tok) + --features print"]
    Print -. "optional npm" .-> PrintWasm["@forma-3d/print\nBrowser WASM 3MF + DFM"]

Five Clean Integration Surfaces

  1. Standalone Binary (forma-print): forma-print check|gate|orient|pack|split|export ... (accepts .forma, .glb, .stl, .obj, or stdin).
  2. Git-Style CLI Dispatch (forma print ...): ~25 LOC in forma-cli / bin/forma.mjs forwards forma <subcmd> to forma-<subcmd> on $PATH (< 1 KB core impact, 0 new deps).
  3. Opt-In MCP Server (forma-print --mcp): Registered separately only for 3D printing workflows — 4 composable tools (print_check, print_prep, print_export, print_profiles) at ~380 o200k tokens (0 tokens on core forma-mcp), plus zero-tool-token MCP prompts & resources (starter build-spec schema, print-gate workflow prompt).
  4. Optional npm WASM (@forma-3d/print): Client-side parametric .3mf + instant DFM heatmaps (~90–130 KB delta over core).
  5. Optional Cargo Feature (--features print): Embeds forma print into forma-cli or /v1/print/* routes into forma-server on demand.

4. Three-Tier Implementation Roadmap

Tier 1 — MVP (Shipped in crates/forma-print, 0 new crates)

  • profiles.rs & fasteners.rs: 16+ verified FDM/SLA/SLS printer & filament profiles plus published ISO 273 / ISO 4762 / DIN 974-1 / heat-set tables with explicit provenance strings.
  • bvh.rs + dfm.rs: Pure-Rust DFM audit (~8–25 ms on 10k tris): watertight/manifold, self-intersection check (reusing forma_core::boolean::check_self_intersections), brim-aware build-volume fit (+ optional informational compact-bed compatibility flag), overhangs, floating islands, bridge vs. unsupported ceilings, BVH inward raycast min/p01 wall thickness screen (with small-face fallback), bed-adhesion/CoM stability, multi-part clearance, AMS swap count, material mass/time estimate.
  • gate.rs (Spec-Driven Production Gate & Active Bore Metrology): Validates an optional declarative spec.json contract (units: "mm", target bbox ± tol, expected shells, min_wall_mm, max_overhang_area_pct, brim_margin_mm, declared bores/D-holes with fastener standards, required_checks) with deterministic exit codes (0 pass, 1 requirement failed, 2 invalid contract). Includes active ray probes for declared holes: axial bore-clear & blind-depth probes (ray reach derived from projected mesh extent along the bore axis, never a fixed cap), 4-quadrant material-around breakout checks, median-of-3 jittered radial ring diameter sampling (immune to tessellation-edge leaks), and D-hole flat splitting (r · cos(φ)). Reports separate checked, unchecked, and exclusions lists so digital screens are never conflated with physical fit, load, thermal, or shrinkage qualification.
  • heatmap.rs: Color-coded 4-view diagnostic PNG (< 4 ms) by assigning a 5-slot DFM severity palette to face.mat_id and calling forma_core::render::render_quad_png_bytes directly (no duplicate renderer).
  • orient.rs: Auto-orientation solver testing planar face clusters + convex-hull facets against weighted (overhangs, islands, support_vol, bed_area, z_height, ams_swaps) in ~15–40 ms.
  • export_3mf.rs (+ Round-Trip Audit): Pure-Rust Deflate-compressed unit="millimeter" 3MF with <basematerials>, <m:colorgroup>, Bambu/Orca Metadata/model_settings.config + project_settings.config, Prusa Slic3r_PE_model.config, embedded 256×256 thumbnail, plus mm-scaled .step. Supports --verify-roundtrip to re-import exported .3mf/.stl bytes via forma_core::import, re-check topology + mm bbox, and emit a manifest.json binding source/spec/output SHA-256 hashes and triangle counts.

Tier 2 — Print-Native CAD, Splitting & Plate Nesting (~2.8k LOC, 0 new crates)

  • SLA Suction-Cup & Trapped-Cavity Detector: Slice-graph tracking of CW inner loops across section_z + enclosed negative shells (~20–60 ms), plus auto-hollow + lowest-Z drain & top vent holes (solidify_mesh + boolean plugs).
  • Multi-Part & Multi-Plate 2D Nesting (nest.rs): Reuses uv.rs's convex-hull rotating calipers + MaxRects packer (< 10 ms for 50 parts), including purge-tower exclusion zones and automatic multi-plate spillover (plate_1.json, plate_2.json, ...).
  • Auto-Split Oversized Parts (split.rs): Minimum-cross-section bisect_mesh + interlocking 15° dovetail or clearance-compensated alignment pin/socket boolean joints.
  • Print-Native Ops & Functional PIP Mechanisms (ops_print.rs): teardrop() horizontal holes, counterbore_bridged() sacrificial 1-layer ceilings, heat_insert() (M2–M5 CNC Kitchen/Voron specs), thread_printable() (45° flanks + clearance), elephant_chamfer(), brim_ears(), snap_fit(), modifier_part tagging, plus parametric print-in-place joints — pip_hinge() (45° chamfered conical pins, zero supports), dovetail_rail(), and living_hinge() — parameterized directly by active printer profile clearances.
  • Coupled Mechanism DFM & Collision-First Mount Selection (dfm.rs / orient.rs): Inspired by the mechanical grounding and swing-collision testing (--hinge=auto) of Functionalization / GraFu (Zhao et al., SIGGRAPH Asia 2026, arXiv:2605.18010), verifies both rest-pose anti-fusion clearance (>= profile.pip_clearance) and full-travel swept clearance (swing_clear / slide_clear), flags weak layer-line shear on hinge pins / snap clips during orient.rs, and deterministically selects collision-free hinge/rail mount offsets without external template assets or ML weights.
  • @forma-3d/print WASM package.

Tier 3 — Slicer CLI Bridge & LAN Fleet Dispatch (opt-in features)

  • slicer.rs (slicer-cli feature, 0 extra crates): Auto-discovers local orca-slicer, BambuStudio, prusa-slicer, or CuraEngine via std::process::Command to return exact sliced print time, per-slot AMS grams, purge grams, and layer count.
  • printer_api.rs (net-lan feature, off by default): Pure-Rust HTTP/1.1 upload & status polling for Klipper/Moonraker and OctoPrint (plus documented Bambu LAN Developer Mode option).
  • Closed-Loop Agent Print Workflow: forma eval → print_check (visual heatmap + metrics) → print_prep (orient, elephant_chamfer, split) → print_export (AMS-ready .3mf) → optional headless slicer verification.