trimesh.interfaces package


trimesh.interfaces.blender module

trimesh.interfaces.blender.boolean(meshes, operation='difference')

trimesh.interfaces.generic module

class trimesh.interfaces.generic.MeshScript(meshes, script, tmpfile_ext='stl', **kwargs)

Bases: object


trimesh.interfaces.gmsh module

trimesh.interfaces.gmsh.load_gmsh(file_name, gmsh_args=None)

Returns a surface mesh from CAD model in Open Cascade Breap (.brep), Step (.stp or .step) and Iges formats Or returns a surface mesh from 3D volume mesh using gmsh.

For a list of possible options to pass to GMSH, check:

An easy way to install the GMSH SDK is through the gmsh-sdk package on PyPi, which downloads and sets up gmsh:

>>> pip install gmsh-sdk
  • file_name (str) – Location of the file to be imported

  • gmsh_args ((n, 2) list) – List of (parameter, value) pairs to be passed to gmsh.option.setNumber

  • max_element (float or None) – Maximum length of an element in the volume mesh


mesh – Surface mesh of input geometry

Return type


trimesh.interfaces.gmsh.to_volume(mesh, file_name=None, max_element=None, mesher_id=1)

Convert a surface mesh to a 3D volume mesh generated by gmsh.

An easy way to install the gmsh sdk is through the gmsh-sdk package on pypi, which downloads and sets up gmsh:

pip install gmsh-sdk

Algorithm details, although check gmsh docs for more information: The “Delaunay” algorithm is split into three separate steps. First, an initial mesh of the union of all the volumes in the model is performed, without inserting points in the volume. The surface mesh is then recovered using H. Si’s boundary recovery algorithm Tetgen/BR. Then a three-dimensional version of the 2D Delaunay algorithm described above is applied to insert points in the volume to respect the mesh size constraints.

The Frontal” algorithm uses J. Schoeberl’s Netgen algorithm. The “HXT” algorithm is a new efficient and parallel reimplementaton of the Delaunay algorithm. The “MMG3D” algorithm (experimental) allows to generate anisotropic tetrahedralizations

  • mesh (trimesh.Trimesh) – Surface mesh of input geometry

  • file_name (str or None) – Location to save output, in .msh (gmsh) or .bdf (Nastran) format

  • max_element (float or None) – Maximum length of an element in the volume mesh

  • mesher_id (int) – 3D unstructured algorithms: 1: Delaunay, 4: Frontal, 7: MMG3D, 10: HXT


data – MSH data, only returned if file_name is None

Return type

None or bytes

trimesh.interfaces.scad module

trimesh.interfaces.scad.boolean(meshes, operation='difference')

Run an operation on a set of meshes

trimesh.interfaces.scad.interface_scad(meshes, script)

A way to interface with openSCAD which is itself an interface to the CGAL CSG bindings. CGAL is very stable if difficult to install/use, so this function provides a tempfile- happy solution for getting the basic CGAL CSG functionality.

  • meshes (list of Trimesh objects) –

  • script (string of the script to send to scad.) – Trimesh objects can be referenced in the script as $mesh_0, $mesh_1, etc.

trimesh.interfaces.vhacd module

trimesh.interfaces.vhacd.convex_decomposition(mesh, **kwargs)

Run VHACD to generate an approximate convex decomposition of a single mesh.


mesh (trimesh.Trimesh) – Mesh to be decomposed into convex components


meshes – List of convex meshes

Return type

(n,) trimesh.Trimesh

Module contents