pythonmeshnumpy-stl

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


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!


Solution

  • 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)