Skip to main content

polyxios

Fast, clean mesh I/O for Python. Read and write 3D mesh files in one line - no hidden surprises, no silent data corruption.


Install

pip install polyxios

or, from conda-forge:

conda install -c conda-forge polyxios

Usage

import polyxios as px

# Read any supported format
mesh = px.read("brain.vtk")

# Inspect
print(mesh.vertices.shape)  # (n_verts, 3)
print(len(mesh.element_types))  # number of elements
print(mesh.topological_dimension)  # 0 points, 1 lines, 2 surfaces, 3 volumes

# Write to a different format
px.write(mesh, "brain.ply")
px.write(mesh, "brain.vtp")

Need binary output or format-specific options?

px.write(mesh, "brain.vtk", binary=True)
px.write(mesh, "brain.ply", binary=True, endian="little")

Files, buffers and streams

Anything with a read or a write works where a path does, so a mesh never has to touch disk:

import io

buf = io.BytesIO()
px.write(mesh, buf, fmt=".ply")  # fmt= names the format

buf.seek(0)
same = px.read(buf, fmt=".ply")

with open("brain.vtk", "rb") as fh:
    mesh = px.read(fh)  # a named handle needs no fmt=

A handle polyxios is given is read or written where it stands and is never closed - the caller keeps control of its own file. A buffer with no file name has no extension to infer a format from, so fmt= is required there; open() gives a handle a name, and that is enough. TetGen is the one format a buffer cannot carry: a mesh is a .node and an .ele file found beside each other.

Compressed files

gzip is transparent for every format at once:

mesh = px.read("brain.vol.gz")  # decompressed on the way in
px.write(mesh, "brain.vtk.gz")  # compressed on the way out
px.write(mesh, buf, fmt=".obj.gz")  # a buffer says it with fmt=

Reading looks at the content, so a file compressed without being renamed reads just as well as one ending in .gz. Writing looks at the name, an output file having no content to inspect yet. The compressed output carries no timestamp and no embedded name, so the same mesh always produces the same bytes.


Command Line Interface (pxios)

polyxios comes with a command-line interface pxios to quickly fetch, list, convert, and visualize 3D models.

Subcommands

--verbose can be given on either side of the subcommand (e.g. pxios --verbose fetch bunny.obj or pxios fetch bunny.obj --verbose) to print debug logs and full tracebacks when a command fails.

  • pxios list: Lists all available remote or cached files, or registered formats. The three listing modes below are mutually exclusive.
    • --local: Lists locally cached files (can filter by optional extension argument, e.g. pxios list obj --local).
    • --extensions / --formats: Lists all formats and extensions available in the remote catalog.
    • --codecs: Lists all formats supported by polyxios codecs.
  • pxios fetch <filename|extension>: Downloads and caches a single model file (e.g., bunny.obj) or every model catalogued for an extension (e.g., obj or .obj).
  • pxios convert <input_file> <output_file>: Converts a model file from one format to another directly in a single process.
  • pxios viz <filename>: Visualizes a local or cached model file using the FURY library.
    • --lines: Render line elements using actor.line instead of rendering as a surface/point cloud.
    • --points: Render strictly as a point cloud.
# List all fetchable remote models
pxios list

# Fetch a single model
pxios fetch bunny.obj

# Fetch every model catalogued for an extension
pxios fetch vtk

# Convert a mesh file
pxios convert bunny.obj bunny.vtk

# Visualize a model
pxios viz bunny.obj

Lazy loading - work with large files without filling RAM

For large meshes (gigabytes of binary data), pass lazy=True. polyxios memory-maps the file and only loads the pages you actually touch - the rest stays on disk until needed.

# File is opened but data is not loaded into RAM yet
mesh = px.read("huge_brain.vtk", lazy=True)

# Only the vertices are pulled from disk here
first_vertex = mesh.vertices[0]

# Element connectivity is still on disk until you access it

lazy=True is honoured for binary .vtk, .ply and .stl files. ASCII formats load eagerly (the whole file must be parsed to extract values). Binary STL lazy mode skips vertex deduplication - vertices are returned as-is (3 per triangle), avoiding the extra pass over the data. .meshb needs no flag: a path is always memory-mapped, so lazy=True there warns and changes nothing.

mmap maps a file descriptor from byte zero, so the formats whose lazy read hands back arrays viewing the mapping need a real, uncompressed file standing at its start: an io.BytesIO, a handle part-way into a file, or a gzipped one raises LazyReadError naming the reason rather than quietly loading eagerly. Binary STL's lazy mode only skips work, so it takes a buffer or a compressed file like any other read.


Supported formats

Format Extension Read Write Notes
VTK Legacy .vtk ✓ ✓ lazy: binary
VTK RectilinearGrid .vtr ✓ ✓ per-axis coordinate arrays, appended or inline base64
VTK PolyData .vtp ✓ ✓ points, lines, polygons, strips
Wavefront OBJ .obj ✓ ✓ vt/vn round trip, groups → element tags
Stanford PLY .ply ✓ ✓ lazy: binary
STL .stl ✓ ✓ lazy: binary, which skips vertex deduplication
OFF .off ✓ ✓ ASCII + big-endian binary, ST/C/N variants → vertex/face attrs
Abaqus .inp ✓ ✓ *NSET/*ELSET → tags, planar cards for a 2-D deck
AVS-UCD .avs ✓ ✓ node/cell/model data → attrs
Medit binary .meshb ✓ ✓ a path is always mmapped; no lazy= needed
Medit ASCII .mesh* .medit ✓ ✓ reference integers → tags; write with fmt=".medit"
DOLFIN / FEniCS XML .xml ✓ ✓ interval/triangle/tetrahedron meshes
FLAC3D .f3grid ✓ ✓ zones + faces, groups → element tags
Gmsh .msh ✓ ✓ (v2) ASCII v2 + v4.1, physical groups → element tags
Nastran .bdf .nas .fem .dat* ✓ ✓ free/small/large field read, free-field write with large-field GRID on request
Tecplot ASCII .tec .dat* ✓ ✓ FE zone, POINT + BLOCK packing, solution variables → vertex attrs; binary .plt is recognised but not read
SU2 .su2 ✓ ✓ ASCII, VTK element codes, boundary markers → element tags
TetGen .ele+.node ✓ ✓ paired files, 1-/0-based indices, boundary markers → vertex tags, region attrs
Well-Known Text .wkt ✓ ✓ 2D padded to z=0, holes → element attrs, EWKT SRID dropped
VTK UnstructuredGrid .vtu ✓ ✓ arbitrary cell-type mix
VTK StructuredGrid .vts ✓ ✓ curvilinear grid, cells implied by the extent (hexahedra, or quads when flat)
VTK ImageData .vti ✓ ✓ origin/spacing/extent only, no coordinate array
MFEM mesh .mesh* ✓ ✓ geometry type codes; INLINE is materialised, NURBS reads back control points
Netgen .vol ✓ ✓ ASCII, points/edges/faces/cells incl. quadratic, bcnr/matnr + names → element tags
UGRID (AFLR) .ugrid ✓ ✓ ASCII, tri/quad surface + tet/pyramid/prism/hex volume, boundary tags → element tags
Gaussian splat .splat ✓ ✓ headerless 32-byte records, points only
Kratos MDPA .mdpa ✓ ✓ ASCII, sub model parts → tags, nodal/elemental data → attrs, conditions read as elements

* .dat belongs to no single format, so it is resolved by content: a Tecplot header lands in the Tecplot codec, a bulk data card in the Nastran one, and anything else reports both candidates. Writing to .dat needs an explicit fmt=. .mesh is MFEM's own extension and Medit ASCII shares it: a file opening with MeshVersionFormatted reads as Medit, one opening with MFEM mesh reads as MFEM, and a bare write goes to MFEM.

.vtm, .pvtu, .pvts, .pvti, .pvtp and .pvtr are registered too, but they hold no geometry - only references to sub-files. Reading one raises UnsupportedFormatError pointing at examples/read_parallel_vtk.py rather than failing with a parse error further in; writing them is not supported.

27 formats supported across the 31 extensions in the table, plus .plt, which is recognised but not read - more coming via the plugin system.


Transforms

Every transform takes a PolyData and returns a new one - nothing is modified in place - so they compose freely.

from functools import partial

from polyxios.transforms import (
    pipeline,
    merge,
    merge_duplicate_vertices,
    filter_element_type,
    remove_orphan_vertices,
)

# Compose transforms into a single function
clean = pipeline(
    partial(filter_element_type, keep="triangle"),
    remove_orphan_vertices,
)
result = clean(mesh)

# Weld coincident vertices - the STL facet soup back into a surface
welded = merge_duplicate_vertices(mesh)
snapped = merge_duplicate_vertices(mesh, tol=1e-6)

# Merge two meshes into one
combined = merge(mesh_a, mesh_b)
Transform What it does
pipeline(*fns) Compose transforms left to right into one callable
merge(*polys) Concatenate several meshes into one, offsetting the indices
filter_element_type(poly, keep=...) Keep only the named element types
remove_orphan_vertices(poly) Drop vertices no element references, remap indices
reindex(poly) Alias of remove_orphan_vertices
merge_duplicate_vertices(poly, tol=...) Weld coincident vertices into one
triangulate(poly) Split every surface element into triangles
extract_surface(poly) Return the boundary faces of a volumetric mesh
vertex_colors(poly) Per-vertex RGB out of the vertex attributes, or None

Add your own format

Any third-party package can teach polyxios to read and write a new format - no fork required, no pull request needed.

Step 1 - write a codec (two functions, nothing more):

# mypackage/abc_codec.py
from polyxios._registry import Codec
from polyxios._types import PolyData


def read(path, *, lazy=False) -> PolyData: ...


def write(poly: PolyData, path, **opts) -> None: ...


def register():
    return ".abc", Codec(read, write)

Step 2 - declare an entry point in your pyproject.toml:

[project.entry-points."polyxios.codecs"]
abc = "mypackage.abc_codec:register"

After pip install mypackage, polyxios picks up .abc automatically - no configuration, no restart needed:

mesh = px.read("model.abc")  # works out of the box

Contributing / Development

Clone the repo, then use spin to manage the development workflow:

pip install spin
spin setup       # add upstream remote + install dev deps (libomp on macOS)
spin install     # build Cython extensions and install
spin install -e  # editable install (source changes reflected immediately)
Command Description
spin setup First-time setup: upstream remote, dev deps, OpenMP on macOS
spin build Build with Meson/ninja
spin install Regular install (compiled)
spin install -e Editable install for development
spin test Run the full test suite
spin test -k <pattern> Run tests matching a name pattern
spin lint ruff linter + formatter check + codespell
spin lint --fix Auto-fix lint and formatting issues
spin docs Build Sphinx documentation
spin docs --clean Wipe _build/ before building
spin docs --open Build and open docs in the browser
spin clean Remove build artifacts and __pycache__
spin release <version> Cut a release: bump version, tag, push, start next dev cycle

See docs/contributing.rst for commit message conventions and the full contributor guide. For the full release workflow see docs/development.rst.


Why polyxios?

  • No silent data corruption - large mesh indices raise an error instead of truncating
  • All element groups preserved - a face belonging to multiple tags stays in all of them
  • Safe on untrusted files - header counts validated before any memory allocation
  • Memory-efficient - lazy mmap loading for large binary files
  • Paths, buffers and gzip alike - one API over files, streams and .gz
  • Works without a compiler - pure Python fallbacks included; Cython hot-paths optional

License

See LICENSE.

Metadata

Release files for polyxios 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polyxios 0.4.0
File Size Uploaded
polyxios-0.4.0.tar.gz 735.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for polyxios 0.4.0
File
polyxios-0.4.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
polyxios-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
polyxios-0.4.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
polyxios-0.4.0-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
polyxios-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
polyxios-0.4.0-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
polyxios-0.4.0-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
polyxios-0.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.28+ x86-64, Linux glibc 2.17+ x86-64 Details
polyxios-0.4.0-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details

Total release size: 7.6 MB

Release files / polyxios-0.4.0.tar.gz

Download URL polyxios-0.4.0.tar.gz
Size 735.6 kB
Tags Source
SHA-256 checksum
How to use checksums
921dd1a5ed930d758ecfb994f0f3ea3094bab0dbc2fc6cc4a05826573c065bb7
BLAKE2b-256 checksum
How to use checksums
49de847a17974ea41663309eff987ae97158f36786f8a287b3e928380cb8f8cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp313-cp313-win_amd64.whl

Download URL polyxios-0.4.0-cp313-cp313-win_amd64.whl
Size 912.9 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
92e73d3426435c077142c1ac73653194122e505cd0098ad63a9efba3c55ab5ed
BLAKE2b-256 checksum
How to use checksums
f392214865d58fecf9546570bbbf7c5f0335566391d4402935fbeb583517197f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL polyxios-0.4.0-cp313-cp313-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 766.8 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
7ddd96f26719629540904020178d303dd8f065ce4dacdd874b6df5f1105da616
BLAKE2b-256 checksum
How to use checksums
5c32599905d8063d561a3dd081228b7a1b94142fd0561fdeef9036053ea47b41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp313-cp313-macosx_11_0_arm64.whl

Download URL polyxios-0.4.0-cp313-cp313-macosx_11_0_arm64.whl
Size 602.3 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
1e4b67c43c74e40461ee7083ad65537e84e0ad2ff6e6339f89973e6af85d8c6d
BLAKE2b-256 checksum
How to use checksums
e1e1e5c515591a76048a7e684f00d766e692dc224d322b352b06e25f57e485f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp312-cp312-win_amd64.whl

Download URL polyxios-0.4.0-cp312-cp312-win_amd64.whl
Size 914.6 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
2cd7263b94a19be9701b182570fe32aeff58f9d4c25ee7bf66b39a4fd0b090f9
BLAKE2b-256 checksum
How to use checksums
3c29c587211f4bc21af46062591df92bfe43f757c143371d1312b09d469f26f5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL polyxios-0.4.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 767.1 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
a8d5c1677b6aeb34ed861cd3e03cf8c0aed730acf5336035e841787052c8838a
BLAKE2b-256 checksum
How to use checksums
977d8c9b82dd81b963534d65d92dcef86bcae136fd66c3e64d14a38c37ed2376
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp312-cp312-macosx_11_0_arm64.whl

Download URL polyxios-0.4.0-cp312-cp312-macosx_11_0_arm64.whl
Size 602.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2ab9e50bbda96c71f969e74eeac331d6fc5777debf9319355b23e1e6f07887ad
BLAKE2b-256 checksum
How to use checksums
3845d08a61b05a920e048d7c008211c7bc176a2f5712fafdd31b5b9965071014
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp311-cp311-win_amd64.whl

Download URL polyxios-0.4.0-cp311-cp311-win_amd64.whl
Size 915.1 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
12494dbb683405d833ea2e52544cc2fc8a564eb450f1ec27303ae5302d5077c8
BLAKE2b-256 checksum
How to use checksums
a28ebd7476381a475ff87fa11df5c9312b41eefe8f6bb70e1d1a43e801f9da7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl

Download URL polyxios-0.4.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl
Size 770.8 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64 Linux glibc 2.28+ x86-64
SHA-256 checksum
How to use checksums
d6ead80bc1dafc21ab4306345fd6d3afc7b2c1438249df75142dbeb7bd1eecf2
BLAKE2b-256 checksum
How to use checksums
95851ceed1b44ac87479de7d86fae83792afeca35f6dc4a100ffc953da73aed7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / polyxios-0.4.0-cp311-cp311-macosx_11_0_arm64.whl

Download URL polyxios-0.4.0-cp311-cp311-macosx_11_0_arm64.whl
Size 602.5 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
2871e65c7aebb415cff35d99cb246255f2ecfdb7c5c4ff7cf445f06550016712
BLAKE2b-256 checksum
How to use checksums
208d269cf4543e1d540ff6f938e48894f7297e36ef7af5ba7d8c8f73328351aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

10 release files

0.3.0

10 release files

0.2.0

10 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page