A cross-platform Qt/C++ desktop application for preparing multi-material resin printing jobs. It imports STL models and STEP assemblies, previews and transforms parts in OpenGL, assigns materials per model or assembly leaf, exports binary slice masks, and produces a merged image sequence with machine-oriented G-code.
The screenshot above is captured from the same Ubuntu CI build that runs the end-to-end application self-test; both generated STL fixtures are loaded in the OpenGL scene rather than mocked for documentation.
The slicing backend and its tests run anywhere with Python 3.10+:
git clone https://github.com/asher0913/multi-material-slicer && cd multi-material-slicer
python3 -m venv .venv && . .venv/bin/activate && pip install -r requirements-dev.txt
python -m unittest discover -s tests -vThese tests cover image normalisation, configuration, the tank planner and a full run to merged
images plus run.gcode. The desktop app needs Qt and CMake; see
Build from source. CI builds it on Ubuntu, runs the headless --selftest on
two demo models and uploads what the self-test produced (per-material masks, merged layers and
run.gcode) as the selftest-output artifact of each run.
Conventional resin slicers assume one material for the entire build. This prototype explores a workflow in which different parts can be assigned to different resin tanks while preserving assembly transforms and minimizing tank changes across layers.
The application combines four engineering concerns in one reproducible system:
- interactive 3D model and assembly manipulation;
- robust STL parsing and STEP-to-STL conversion;
- per-material rasterization at printer resolution;
- deterministic scheduling, image merging, and G-code generation.
- Import ASCII or binary STL files with malformed-file, overflow, NaN/Inf, and file-size validation.
- Import STEP/STP assemblies through an OpenCascade helper while preserving nested assembly paths in the model tree.
- Apply translation, rotation, and scale at either assembly or leaf level.
- Assign individual materials without breaking relative assembly placement.
- Preview models with an OpenGL VBO renderer and configurable build plate.
- Export per-material PNG masks in a background worker with progress, cancellation, and a ten-minute backend timeout.
- Plan layer-by-layer tank transitions and generate merged exposure images plus
run.gcode. - Package the Python image-merging and STEP helpers as standalone executables for macOS and Windows.
- Run a headless
--selftestthat exercises model import, raster export, configuration generation, image merging, and G-code output.
STL / STEP input
|
v
STL parser or OpenCascade converter
|
v
Assembly-aware scene model --> Qt/OpenGL preview and editing
|
v
Per-material slice exporter
|
+--> material_0/1.png, material_1/1.png, ...
|
v
Python merge backend --> merged PNG sequence + run.gcode
See the architecture notes for module boundaries, failure handling, and design trade-offs.
- CMake 3.16+
- A C++17 compiler
- Qt 5.12+ with Widgets and OpenGL
- Python 3.10+
- Python packages from
requirements.txt
Install the Python backend dependencies in a virtual environment:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r requirements.txtConfigure and build the application. Point CMAKE_PREFIX_PATH to Qt only when
Qt is not already discoverable by CMake:
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallelOn macOS with a standalone Qt installation:
cmake -S . -B build -DCMAKE_PREFIX_PATH="$(qmake -query QT_INSTALL_PREFIX)"
cmake --build build --parallelFrom the repository root:
./build/MultiMaterialSlicerThe repository contains generated demo models under demo_stl/ and an
anonymized two-part STEP example under demo_step/.
Run the end-to-end smoke test without interacting with the UI:
xvfb-run --auto-servernum ./build/MultiMaterialSlicer --selftest \
demo_stl/multi_A_base_plate.stl \
demo_stl/multi_B_cross_insert.stlOn macOS, omit xvfb-run and launch the binary directly.
The image-merging backend can also run independently:
python slice_1080p.py --config /path/to/config.yaml --output /path/to/jobThe configuration identifies one PNG directory per material, printer motion
parameters, exposure settings, and permitted tank-to-tank transitions. The
backend normalizes image dimensions, schedules material changes, writes merged
exposure masks, and generates run.gcode.
The STEP converter is optional and requires CadQuery/OCP:
python -m pip install -r requirements-step.txt
python tools/step_to_stl_parts.py \
--input demo_step/two-part-assembly.step \
--output /tmp/mms-step-partsGitHub Actions performs the following checks on every push and pull request:
- Python compilation and unit tests for configuration, image normalization, transition planning, and end-to-end G-code generation.
- CMake configuration and a full Qt/C++ build on Ubuntu.
- XML validation for the Qt Designer file.
- An Xvfb-backed application self-test using two STL models.
Run the portable Python checks locally with:
python -m pip install -r requirements-dev.txt
ruff check slice_1080p.py tools tests
python -m unittest discover -s tests -v| Behaviour | Checked in CI? |
|---|---|
| Backend: normalisation, config expansion, tank planning, G-code generation | Yes: unit tests |
| Full C++/Qt build on Ubuntu | Yes |
STL import → OpenGL scene → per-material masks → merge → run.gcode |
Yes: --selftest under Xvfb, with the output uploaded as an artifact |
| UI screenshot in this README | Yes: captured from the same CI build |
| STEP/OpenCascade conversion | No: CadQuery/OCP makes the CI image too large. Run tools/step_to_stl_parts.py locally. |
| macOS and Windows packaging | No: run the scripts under scripts/ on each platform |
| Behaviour on a real printer | No: G-code must be validated on the target machine |
| File | What to look at |
|---|---|
src/StlMesh.cpp |
ASCII and binary STL parsing with size, triangle-count and NaN/Inf validation before allocation |
src/OpenGLView.cpp |
VBO renderer, build plate and orbit camera |
src/SliceExporter.cpp |
cuts each layer plane through the meshes into segments, then scanline-fills them into per-material PNG masks (rasterizeSegments) |
src/SliceWorker.cpp |
background export thread with progress, cancellation and the backend timeout |
src/MainWindow.cpp |
assembly tree, material assignment, the --selftest path |
src/ConfigWriter.cpp, src/PresetLoader.cpp |
job configuration and validated machine presets |
slice_1080p.py |
SliceMerger: _plan_tank_path (dynamic programming over layers × tanks that minimises tank changes, O(L·M²)), _write_job (merged images and G-code) |
tools/step_to_stl_parts.py |
STEP assembly → per-part STL plus a JSON manifest of assembly paths |
Packaging scripts live under scripts/:
package_macos.shbuilds a native application bundle, packages the helpers, runsmacdeployqt, and createsdist/MultiMaterialSlicer-mac-<arch>.zip.package_windows.ps1builds the helpers, runswindeployqt, performs an optional self-test, and createsdist/MultiMaterialSlicer-win64.zip.
The scripts create isolated virtual environments under the ignored
backend_build/ directory. Generated applications, helpers, and archives are
never committed to Git.
- This is an engineering prototype, not production printer-control software.
- G-code semantics and machine presets must be validated against the target printer before operating hardware.
- The checked-in CI validates STL import. STEP conversion is tested separately because CadQuery/OCP substantially increases CI time and image size.
- The interface is currently localized primarily in Simplified Chinese; the code and public documentation use English identifiers and descriptions.
- Release binaries are not code-signed with a commercial certificate.
config/ machine and material presets
demo_step/ anonymized STEP assembly fixture
demo_stl/ generated STL fixtures
docs/ architecture and design notes
resources/ Qt styles and icons
scripts/ macOS and Windows packaging automation
src/ Qt/C++ application
tests/ Python backend regression tests
tools/ demo-model and STEP conversion utilities
ui/ Qt Designer interface
The original source code is released under the MIT License. Third-party frameworks and optional packaging dependencies retain their own licenses; see THIRD_PARTY_NOTICES.md.
