From a153e1e41cf53f7a2bcccc55cc0c6281427861f3 Mon Sep 17 00:00:00 2001 From: Christian Hodgden Date: Sat, 9 Nov 2024 20:45:55 +0000 Subject: lib>measure_stl: Added volume reporting --- lib/measure_stl.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/lib/measure_stl.py b/lib/measure_stl.py index 8abd81b..de0d0c7 100755 --- a/lib/measure_stl.py +++ b/lib/measure_stl.py @@ -8,23 +8,25 @@ from stl import mesh -file_path = './dummy13/src/armor-crotch-v12.stl' -#file_path = './dummy13/src/armor-waist-v30.stl' -#file_path = './dummy13/src/frame-hips-v3.stl' -mesh = mesh.Mesh.from_file(file_path) +file_path = './candles/diamond.stl' +model_mesh = mesh.Mesh.from_file(file_path) -x_min = mesh.x.min() -x_max = mesh.x.max() -y_min = mesh.y.min() -y_max = mesh.y.max() -z_min = mesh.z.min() -z_max = mesh.z.max() +x_min = model_mesh.x.min() +x_max = model_mesh.x.max() +y_min = model_mesh.y.min() +y_max = model_mesh.y.max() +z_min = model_mesh.z.min() +z_max = model_mesh.z.max() length = x_max - x_min width = y_max - y_min height = z_max - z_min +volume, cog, inertia = model_mesh.get_mass_properties() + print(f'measurements of {file_path.split("/")[-1]}') print(f'x range: {x_min}, {x_max}: {length}') print(f'y range: {y_min}, {y_max}: {width}') print(f'z range: {z_min}, {z_max}: {height}') - +print(f'Volume: {volume} cubic units') +print(f'Center of Gravity: {cog}') +print(f'Inertia Matrix: {inertia}') -- cgit v1.2.3