trimesh.boolean

boolean.py

Do boolean operations on meshes using either Blender or Manifold.

trimesh.boolean.boolean_manifold(meshes: Iterable, operation: str, check_volume: bool = True, debug: bool = False, **kwargs)

Run an operation on a set of meshes using the Manifold engine.

Parameters:
  • meshes (list of trimesh.Trimesh) – Meshes to be processed

  • operation – Which boolean operation to do.

  • check_volume – Raise an error if not all meshes are watertight positive volumes. Advanced users may want to ignore this check as it is expensive.

  • debug – Enable potentially slow additional checks and debug info.

  • kwargs – Passed through to the engine.

trimesh.boolean.difference(meshes: Iterable, engine: str | None = None, check_volume: bool = True, **kwargs)

Compute the boolean difference between a mesh an n other meshes.

Parameters:
  • meshes (sequence of trimesh.Trimesh) – Meshes to be processed.

  • engine – Which backend to use, i.e. ‘blender’ or ‘manifold’

  • check_volume – Raise an error if not all meshes are watertight positive volumes. Advanced users may want to ignore this check as it is expensive.

  • kwargs – Passed through to the engine.

Returns:

A Trimesh that contains meshes[0] - meshes[1:]

Return type:

difference

trimesh.boolean.intersection(meshes: Iterable, engine: str | None = None, check_volume: bool = True, **kwargs)

Compute the boolean intersection between a mesh and other meshes.

Parameters:
  • meshes (list of trimesh.Trimesh) – Meshes to be processed

  • engine (str) – Which backend to use, i.e. ‘blender’ or ‘manifold’

  • check_volume – Raise an error if not all meshes are watertight positive volumes. Advanced users may want to ignore this check as it is expensive.

  • kwargs – Passed through to the engine.

Returns:

A Trimesh that contains the intersection geometry.

Return type:

intersection

trimesh.boolean.union(meshes: Iterable, engine: str | None = None, check_volume: bool = True, **kwargs)

Compute the boolean union between a mesh an n other meshes.

Parameters:
  • meshes (list of trimesh.Trimesh) – Meshes to be processed

  • engine (str) – Which backend to use, i.e. ‘blender’ or ‘manifold’

  • check_volume – Raise an error if not all meshes are watertight positive volumes. Advanced users may want to ignore this check as it is expensive.

  • kwargs – Passed through to the engine.

Returns:

A Trimesh that contains the union of all passed meshes.

Return type:

union