cmvr-es/script/tool/de_stl_faces.py

23 lines
529 B
Python
Raw Permalink Normal View History

2025-12-05 16:33:11 +08:00
import trimesh
path = "R_WRIST_R_S.STL"
obj = trimesh.load(path)
if isinstance(obj, trimesh.Scene):
mesh = trimesh.util.concatenate(list(obj.geometry.values()))
else:
mesh = obj
print("原始面数:", len(mesh.faces))
# 想删掉 80% 的面(保留 20%
target_reduction = 0.8 # 0~1 之间
mesh_simplified = mesh.simplify_quadric_decimation(target_reduction)
print("简化后面数:", len(mesh_simplified.faces))
out_path = "R_WRIST_R_S_low.STL"
mesh_simplified.export(out_path)
print("已导出:", out_path)