wolph / numpy-stl

Simple library to make working with STL files (and 3D objects in general) fast and easy.
http://numpy-stl.readthedocs.org/
BSD 3-Clause "New" or "Revised" License
605 stars 103 forks source link

Issues with combining two STL files #151

Closed CRRMCF closed 3 years ago

CRRMCF commented 3 years ago

Hi,

I am using the package to combine two STL files into one part. The 1st STL file serves as the main body and the 2nd STL file shall be inside the 1st part, and both of them share the same origin (x=0, y=0, z=0). To do so, I have followed the examples provided as "Combining Multiple STL files", however, issues are the following when I have the final STL file:

  1. The 2nd part is separate away from the 1st part, not inside of the 1st part;
  2. There are 2 extra copies of these parts. image
  3. How can I export the combined STL file into a numpy array?

Thank you so much!

wolph commented 3 years ago

Looking at the results I would think that the origin is somehow not correct for one (or both) of the models. You could try moving them to the zero point by subtracting the offset for both before combining them:

mesh_a.x -= mesh_a.x.min()
mesh_a.y -= mesh_a.y.min()
mesh_a.z -= mesh_a.z.min()

mesh_b.x -= mesh_b.x.min()
mesh_b.y -= mesh_b.y.min()
mesh_b.z -= mesh_b.z.min()