Skip to main content

Overview

The 3MF export module converts Manifold CSG geometry to the 3MF file format, optimized for BambuStudio and other modern slicers. It uses JSZip to package the 3MF archive structure.

Import

Types

TriangleMesh

Intermediate mesh format for 3MF export.
Source: src/gridfinity/export3mf.ts:3-6
Float32Array
required
Flat array of vertex positions (3 floats per vertex: x, y, z)
Uint32Array
required
Flat array of triangle vertex indices (3 indices per triangle)

Functions

manifoldToTriangleMesh

Converts a Manifold object to TriangleMesh format.
Manifold
required
Manifold geometry object
Returns: TriangleMesh with vertices and triangles. Source: src/gridfinity/export3mf.ts:9-25 Example:

exportTo3MF

Packages triangle meshes into a 3MF file (ZIP archive).
Array<{mesh: TriangleMesh, name: string}>
required
Array of meshes to include in the 3MF file. Each mesh has:
  • mesh: The triangle mesh data
  • name: Display name for the object in the slicer
Returns: Promise resolving to a Blob containing the 3MF file. Source: src/gridfinity/export3mf.ts:98-168 Example:

downloadBlob

Triggers browser download of a Blob.
Blob
required
File data to download
string
required
Suggested filename for download
Source: src/gridfinity/export3mf.ts:171-178 Example:

3MF File Structure

The exported 3MF file follows the OPC (Open Packaging Conventions) ZIP structure:

Key Files

[Content_Types].xml Defines MIME types for 3MF components:
Source: src/gridfinity/export3mf.ts:105-111 3D/3dmodel.model Contains mesh geometry in 3MF XML format:
Source: src/gridfinity/export3mf.ts:144-165 Metadata/model_settings.config Critical for BambuStudio detection:
Source: src/gridfinity/export3mf.ts:121-129
Without model_settings.config, BambuStudio will reject the file. This file is required for proper import.

Multi-Object Export

The exporter supports multiple objects in a single 3MF file:

Object ID Scheme

Each mesh generates two objects:
  • Volume object (odd ID): Contains mesh geometry
  • Parent object (even ID): References volume as component, carries name
Source: src/gridfinity/export3mf.ts:39-86

Build Items

Only parent objects appear in the build plate:
Source: src/gridfinity/export3mf.ts:88-95

Usage Pattern

Complete workflow from Manifold geometry to downloaded 3MF:

BambuStudio Compatibility

The exporter includes specific metadata for BambuStudio:

Required Metadata

Source: src/gridfinity/export3mf.ts:151-152

Namespace Declarations

Source: src/gridfinity/export3mf.ts:145-149

UUID Generation

Each build item receives a unique UUID:
Source: src/gridfinity/export3mf.ts:31-37

Coordinate System

The 3MF format uses millimeters with right-handed coordinates:
  • Units: millimeter (explicitly declared)
  • Origin: Bottom-left-front corner
  • Axes:
    • +X: Right
    • +Y: Back
    • +Z: Up
Manifold geometry is generated in this coordinate system, so no transformation is needed.

XML Escaping

Object names are XML-escaped to prevent parsing errors:
Source: src/gridfinity/export3mf.ts:27-29 Example:

Compression

The 3MF ZIP archive uses DEFLATE compression:
Source: src/gridfinity/export3mf.ts:167 This balances file size with decompression speed.

Error Handling

The export functions do not throw errors for invalid geometry. Ensure:
  • Manifold objects are valid (no self-intersections)
  • Meshes are watertight (closed surfaces)
  • Vertex and triangle arrays are properly formed
Validation:

Performance

Mesh Conversion

Manifold mesh extraction is fast (< 10ms for typical bins):

3MF Generation

JSZip operations are asynchronous and depend on mesh complexity:
  • Small bins (< 10k triangles): ~50ms
  • Large bins (> 50k triangles): ~200ms
  • Multiple objects: Linear scaling

Memory Usage

TriangleMesh stores raw Float32Array and Uint32Array:
Typical bin: 2-5 MB in memory, 500 KB compressed in 3MF.