How do you extract faces from a numpy-stl mesh?

1.4k Views Asked by At

I've read the documentation and searched the internet, however, couldn't reach any useful information.
I'm loading a mesh from file into python using:

import numpy
from stl import mesh
tank = mesh.Mesh.from_file('tank.stl')

Now I need to extract faces of this tank model, any help appreciated, thanks in advance!

1

There are 1 best solutions below

1
JohnB On BEST ANSWER

With the package trimesh:

# Package
import trimesh

myobj = trimesh.load_mesh("tank.stl", enable_post_processing=True, solid=True) # Import Objects
myobj.show()
print(myobj.faces)