Trimesh

4.11.5 · active · verified Thu Apr 09

Trimesh is a Python library for loading, viewing, processing, and analyzing triangular meshes, with a strong emphasis on vectorized operations for performance. It's actively developed and frequently updated, providing a comprehensive set of tools for 3D geometry manipulation.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates creating a basic mesh, performing common analyses like volume and area calculation, and loading a mesh from a remote URL. It focuses on core functionality that doesn't require interactive display.

import trimesh
import numpy as np

# 1. Create a simple mesh (a box)
mesh = trimesh.creation.box()

# 2. Perform basic analyses
volume = mesh.volume
area = mesh.area
inertia = mesh.moment_inertia

print(f"Mesh volume: {volume:.2f}")
print(f"Mesh surface area: {area:.2f}")
print(f"Mesh moment of inertia:\n{inertia}")

# 3. Load a remote mesh (requires network access)
try:
    # Using a known stable URL for demonstration
    mesh_loaded = trimesh.load_remote('https://raw.githubusercontent.com/mikedh/trimesh/main/models/feature.stl')
    print(f"Loaded remote mesh, volume: {mesh_loaded.volume:.2f}")
except Exception as e:
    print(f"Could not load remote mesh: {e}. Check internet connection or URL.")

view raw JSON →