technical3mfexportbambu-lab

Building the 3MF Export Pipeline: From Pixels to Print-Ready Files

A deep dive into how ColorLayer converts image pixels into optimized 3MF files compatible with BambuStudio, including geometry generation and multi-material encoding.

ColorLayer TeamOctober 25, 20243 min read
Building the 3MF Export Pipeline: From Pixels to Print-Ready Files

One of the core technical challenges in building ColorLayer was creating a reliable 3MF export pipeline. The 3MF format is essentially a ZIP archive containing XML files that describe 3D geometry, materials, and slicer settings. Getting every detail right is what makes the difference between a file that "opens" and a file that actually prints correctly.

What is 3MF?

The 3MF (3D Manufacturing Format) is an open standard developed by the 3MF Consortium. Unlike STL files, 3MF supports:

  • Multiple materials per model
  • Color information embedded in the geometry
  • Print settings like layer height and infill
  • Textures and metadata

For multi-color printing, 3MF is essential because it can encode which filament belongs to which triangle in the mesh.

Our Export Pipeline

ColorLayer's export pipeline has four stages:

Stage 1: Color Stack Computation

For every pixel in the processed image, ColorLayer determines the optimal stack of filament layers. Each pixel maps to a sequence like [White, Cyan, Magenta] that will produce the closest color match when printed.

Stage 2: Region Extraction

Adjacent pixels with the same color stack are grouped into rectangular regions using a greedy meshing algorithm. This dramatically reduces the triangle count compared to generating individual cubes per pixel.

Early versions of ColorLayer generated one rectangular prism per pixel. For a 200x200 image, that was 40,000 cubes — 480,000 triangles. With greedy meshing, the same image typically produces a few thousand rectangles, reducing triangle count by 10-50x.

Stage 3: Geometry Generation

Each rectangular region becomes a 3D box with the appropriate height and material assignments. The geometry is structured so that each layer of the stack is a separate sub-mesh that can be assigned a different filament.

The base layer, if enabled, is generated as a single continuous mesh with the selected shape (rectangle, rounded, or contour).

Stage 4: 3MF Assembly

Finally, all geometry is assembled into the 3MF archive:

  • 3D/3dmodel.model — The mesh data with material references
  • Metadata/plate_1.config — BambuStudio-specific print settings
  • [Content_Types].xml — Standard OPC package types
  • _rels/.rels — Package relationships

BambuStudio Compatibility

Getting 3MF files to work correctly in BambuStudio required careful attention to several details:

Parameter Overrides

When overriding slicer parameters like layer_height, you must add the parameter name to the different_settings_to_system array. Without this, BambuStudio silently ignores your overrides.

Material Indexing

BambuStudio expects materials to be indexed starting from 1, with the index corresponding to the AMS slot number. Color assignments in the mesh reference these indices.

Orientation

ColorLayer supports both color-up and color-down orientations. Color-down produces a smoother surface finish (the first layer against the build plate is always the smoothest) but the model must be flipped during export.

Lessons Learned

Building a robust 3MF exporter taught us several lessons:

  1. Test with real prints, not just the slicer — A file can look correct in BambuStudio but produce unexpected results on the printer
  2. Memory matters — Large images can produce meshes with millions of triangles. Greedy meshing and async yield points prevent browser crashes
  3. Standards vary — What the 3MF spec says and what BambuStudio expects are not always the same

Try It Yourself

Upload any image to ColorLayer, export a 3MF, and open it in BambuStudio. You will see a fully configured multi-color model ready to print.


Interested in the technical details of the 3MF format? Check out the 3MF Consortium's specification for the full standard.

C

ColorLayer Team

Author

Related Posts