Automatically find the optimal 3D print orientation that minimizes support material — saving filament, reducing print time, and improving surface quality.
Popular slicers like Bambu Studio generate support structures for overhanging geometry, but they do not search for the optimal print orientation that minimizes the amount of support material needed. The model is simply printed in whatever orientation it was imported in — leaving users to manually rotate their models and guess at the best angle, often wasting filament on unnecessary supports.
We initially attempted to integrate this optimization feature directly into Slic3r, the popular open-source slicer. However, the Slic3r codebase proved extremely difficult to extend — its architecture made adding a new optimization pass impractical. We decided to build a standalone tool modeled after the original program, with its own UI designed to replicate the familiar slicer workflow while giving us full control over the optimization pipeline.
-
Overhang Detection — Triangles whose face normals exceed a configurable overhang threshold are identified as requiring support.
-
Loss Functions — Two loss functions quantify the cost of support material for a given orientation:
- Naive — Sums the distance from each overhanging triangle to the build plate, weighted by face area. Fast but ignores internal geometry.
- Hole-Aware — Casts rays upward from the build plate and uses inside/outside logic to skip distances that fall within the solid body of the model. More accurate for meshes with holes or internal cavities.
-
Orientation Optimization — Searches over Euler angles (rx, ry, rz) to minimize the chosen loss:
Optimizer Strategy deDifferential Evolution (SciPy) — robust global search bayesBayesian Optimization (scikit-optimize) — sample-efficient GP surrogate cmaCMA-ES — covariance matrix adaptation ctfCoarse-to-Fine — grid search → CMA-ES refinement -
Mesh Decimation — Optionally simplify the mesh via quadric decimation during the search to speed up evaluation, then apply the best rotation to the original full-resolution mesh.
git clone https://github.com/<your-username>/SupportStructureMinimization.git
cd SupportStructureMinimization
python -m venv env && source env/bin/activate # Windows: env\Scripts\activate
pip install -r requirements.txtpython src/ui.pyBrowse for an input mesh, configure optimization parameters, run the optimizer, and export — all from the GUI.
# Optimize orientation and export
python src/main.py models/3DBenchy.stl output.obj --optimize
# Bayesian optimizer with hole-aware loss
python src/main.py models/teapot.obj output.obj --optimize --optimizer bayes --loss hole
# Decimate for faster search on large meshes
python src/main.py models/cat.obj output.obj --optimize --decimate --sim-faces 1000
# Visualize result with ground plane
python src/main.py models/3DBenchy.stl output.obj --optimize --visualize
# Custom overhang threshold
python src/main.py models/3DBenchy.stl output.obj --optimize --overhang 20| Argument | Description | Default |
|---|---|---|
mesh |
Input mesh file (.obj / .stl) |
required |
output |
Output path for the optimized mesh | required |
--optimize |
Enable orientation optimization | off |
--optimizer |
de · bayes · cma · ctf |
de |
--loss |
naive · hole |
naive |
--overhang |
Overhang threshold (degrees) | 15 |
--decimate |
Simplify mesh during search | off |
--sim-faces |
Target face count for decimation | 0 |
--sim-aggression |
Decimation aggression level | 4 |
--visualize |
Open 3D viewer with ground plane | off |
├── src/
│ ├── main.py # Entry point & optimization pipeline
│ ├── loss.py # Naive and hole-aware loss functions
│ ├── optimizer.py # DE, Bayesian, CMA-ES, coarse-to-fine
│ ├── ui.py # Tkinter GUI
│ ├── convdef.py # Convexity deficit utility
│ ├── dimpled_spheres.py # Parameterized test mesh generator
│ ├── generate_meshes.sh # Batch mesh generation
│ └── torus_knot.scad # OpenSCAD torus-knot models
├── scripts/ # Data collection & charting
├── models/ # Sample meshes (Benchy, teapot, cat, etc.)
├── data/ # Experiment results
└── requirements.txt
| Package | Purpose |
|---|---|
trimesh[easy] |
Mesh loading, manipulation, ray casting |
fast-simplification |
Quadric mesh decimation |
scikit-optimize |
Bayesian optimization (Gaussian Process) |
cma |
CMA-ES optimizer |
matplotlib |
Result visualization |
| Name | |
|---|---|
| 🔧 | Ryan Crosier |
| 🔧 | Oguz Elgin |
| 🔧 | Andrew Cho |
This project is released under the MIT License.
