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
628 stars 107 forks source link

How can i find linear parameters of stl model? #220

Closed PeterBan11 closed 7 months ago

PeterBan11 commented 9 months ago

I tried this code:

your_mesh = mesh.Mesh.from_file('dog.stl')
xyz = (your_mesh.max_ - your_mesh.min_)

len = xyz[0]
wid = xyz[1]
heig = xyz[2]

Is it correct?

What is the length measured in your libraries? Is it measured in millimeters?

wolph commented 9 months ago

It's slightly more complicated than that unfortunately. STL files are composed of triangles so you need to make sure you compare each point to each other point.

You are currently comparing the first point of each triangle while ignoring the other 2 points. This will be close to the actual number, but it will usually differ slightly. To get the correct calculation you need to use your_mesh.points.max() - your_mesh.points.min()

The STL format does not specify a unit so the sizes can be measured in millimeters, meters, inches or something completely different depending on your source. Having that said, most of the 3D print STL files you can find online are in millimeters but there is no guarantee for that.

github-actions[bot] commented 8 months ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days