Skip to content

mmgpy

Python bindings for the MMG remeshing library.

Get Started API Reference


Features

3D Volume Meshing Tetrahedral remeshing
2D Meshing Triangular remeshing for planar domains
Surface Meshing 3D surface remeshing and optimization
Local Sizing Sphere, box, cylinder, and point-based refinement
Anisotropic Metrics Custom metric tensors for directional adaptation
Level-Set Extract isosurfaces from implicit functions
Lagrangian Motion Remesh while preserving displacement fields
PyVista Integration Seamless conversion for visualization
40+ File Formats VTK, STL, OBJ natively; GMSH and more via pyvista[io]

Quick Start

import pyvista as pv
import mmgpy  # noqa: F401  -- registers the Medit reader/writer + .mmg accessor

# Load a mesh from any supported format (mmgpy registers a Medit plugin)
mesh = pv.read("input.mesh")

# Remesh with target edge size (returns a fresh dataset)
remeshed = mesh.mmg.remesh(hmax=0.1)

# Save the result
remeshed.save("output.vtk")

Installation

pip install mmgpy
uv pip install mmgpy
# or: uv add mmgpy (project dependency)
# or: uv tool install mmgpy (mmg2d_O3, mmg3d_O3, mmgs_O3 globally)

Mechanical piece remeshing Surface remeshing of a mechanical part

Smooth surface remeshing Smooth surface mesh optimization

3D mesh quality improvement 3D volumetric mesh quality improvement

Learn More