computed-axial-lithography / VAMToolbox

Other
28 stars 11 forks source link

[feature request] Auto center mesh #23

Open twaddellberkeley opened 3 weeks ago

twaddellberkeley commented 3 weeks ago

Center the mesh based on bounding box. import trimesh

Load the mesh

mesh = trimesh.load('path/to/your/mesh_file.obj') # Replace with your file path

Center the mesh at the origin

mesh.apply_translation(-mesh.center_mass)

Alternatively, to center it based on the bounding box center

mesh.apply_translation(-mesh.bounds.mean(axis=0))

Save or display the centered mesh

mesh.show() # Display if you want to visualize

mesh.export('path/to/centered_mesh.obj') # Save if needed