Fix 3MF analysis: concatenate scene geometries instead of force="mesh"

trimesh loads 3MF files as a Scene; force="mesh" fails on those.
Detect Scene and concatenate all geometries before computing extents/volume.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Martin Hohenberg
2026-06-19 10:56:21 +02:00
parent 1e74b3a149
commit ab52721c7f

View File

@@ -23,7 +23,11 @@ def analyse(filename: str, db: Session) -> StlCache | None:
try:
import trimesh
mesh = trimesh.load(str(filepath), force="mesh")
loaded = trimesh.load(str(filepath))
if isinstance(loaded, trimesh.Scene):
mesh = trimesh.util.concatenate(list(loaded.geometry.values()))
else:
mesh = loaded
extents = mesh.extents # [size_x, size_y, size_z] in mm
volume_mm3 = abs(mesh.volume) # mm³ (negative for inverted normals)
entry = StlCache(