Import, export, process, analyze and view triangular meshes.
For the easiest install with only these minimal dependencies (slower ray queries, no vector path handling, mesh creation, viewer, etc):
pip install trimesh
For more functionality, the easiest way to get a full
trimesh install is a conda environment:
# this will install all soft dependencies available on your current platform conda install -c conda-forge trimesh
Further information is available in the advanced installation documentation.
- Import meshes from binary/ASCII STL, Wavefront OBJ, ASCII OFF, binary/ASCII PLY, GLTF/GLB 2.0, 3MF, XAML, 3DXML, etc.
- Import and export 2D or 3D vector paths from/to DXF or SVG files
- Export meshes as binary STL, binary PLY, ASCII OFF, GLTF/GLB 2.0, COLLADA, dictionaries, JSON- serializable dictionaries (base64 encoded arrays), MSGPACK- serializable dictionaries (binary string arrays)
- Preview meshes using pyglet
- Preview meshes in- line in jupyter notebooks using three.js
- Automatic hashing of numpy arrays for change tracking (MD5, zlib CRC, and xxhash)
- Internal caching of computed values validated using numpy hashes
- Fast loading of binary files through importers written by defining custom numpy dtypes
- Calculate things like face adjacencies, face angles, vertex defects, etc.
- Calculate cross sections (IE the slicing operation used in 3D printing)
- Split mesh based on face connectivity using networkx, graph-tool, or scipy.sparse
- Fix triangle winding and normals to be consistent
- Find convex hulls of meshes
- Compute a rotation/translation/tessellation invariant identifier for meshes
- Determine duplicate meshes from identifier
- Determine if a mesh is watertight, convex, etc.
- Repair single triangle and single quad holes
- Uniformly sample the surface of a mesh
- Ray-mesh queries including location, triangle id, etc.
- Boolean operations on meshes (intersection, union, difference) using OpenSCAD or Blender as backend
- Voxelize watertight meshes
- Subdivide faces of a mesh
- Minimum volume oriented bounding boxes for meshes
- Minimum volume bounding sphere / n-spheres
- Symbolic integration of function(x,y,z) over a triangle
- Calculate nearest point on mesh surface and signed distance
- Determine if a point lies inside or outside of a mesh using signed distance
- Create primitive objects (Box, Sphere, Extrusion) which are subclassed Trimesh objects and have all the same features (inertia, viewers, etc)
- Simple scene graph and transform tree which can be rendered (pyglet) or exported.
Design Use Case
trimesh.Trimesh object is most useful on single body, watertight meshes that represent a volume. The design use case is around analysis of geometry exported from a CAD system into a mesh format, for applications related to robotics and manufacturing.
This can be seen in the data model of Trimesh, where the emphasis is on faces and vertices and things derived from them, rather than other visual properties or metadata.
It is hopefully useful in other applications, but most of the core effort is around the design use case.
Trimesh includes an optional pyglet- based viewer for debugging/inspecting. In the mesh view window:
- dragging rotates the view
- ctl + drag pans
- mouse wheel zooms
- 'z' returns to the base view
- 'w' toggles wireframe mode
- 'c' toggles backface culling
If you want to deploy something in a container that uses trimesh, automated builds containing trimesh and its dependencies are available on Docker Hub:
docker pull mikedh/trimesh
Release history Release notifications | RSS feed
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size trimesh-2.31.39.tar.gz (255.7 kB)||File type Source||Python version None||Upload date||Hashes View|