// read_anything()
Reading 3D meshes in Python normally means installing one library per format. polyxios is a single small, maintained package that reads and writes all forty-four - and raises instead of quietly corrupting your data.
import polyxios as px mesh = px.read("brain.vtk") mesh.vertices.shape # (n, 3) len(mesh.element_types) # 2 px.write(mesh, "brain.ply") px.write(mesh, "brain.stl", binary=True) # gigabytes? memory-map it mesh = px.read("huge.vtk", lazy=True) # a buffer or a .gz, same call mesh = px.read(buf, fmt=".ply") mesh = px.read("brain.vol.gz")█
01 // formats
Every format carries its own page: what the specification says, what polyxios does with it, and a link to the authoritative document.
} // 44 codecs, the 56 extensions above plus .plt, recognised but not read - .svg is written, never read; .mesh is shared by Medit ASCII and MFEM, .msh by Gmsh and Fluent, each resolved by content
02 // guarantees
[00]
Large mesh indices raise an error instead of quietly truncating to a narrower integer.
[01]
A face belonging to several tags stays in all of them, through a full read-write round trip.
[02]
Header counts are validated before any memory is allocated for the body.
[03]
Pure Python fallbacks ship with the package; the Cython hot-paths are optional.
03 // cli
Ships with the package. Pull a catalogued model, convert it, and render it through FURY without writing a script.
$ pxios fetch stanford-bunny.obj Successfully fetched to: ~/.polyxios/obj/stanford-bunny.obj $ pxios convert stanford-bunny.obj bunny.vtk Reading 'stanford-bunny.obj'... Read in 0.1680 seconds Writing to 'bunny.vtk'... Wrote in 0.0476 seconds Conversion successful. $ pxios list --codecs File formats supported by polyxios codecs: abaqus (.inp) ... medit (.medit, .meshb) medit/mesh (.mesh) ... permas/tecplot/nastran (.dat) ... tecplot (.plt, .tec) ... wkt (.wkt) $ pxios viz bunny.vtk --points Reading bunny.vtk ... Loaded in 0.0814 seconds 35947 vertices | 69451 elements | vertex attrs: none Opening FURY window ... Rendering strictly as point cloud per --points request.
04 // plugins
Any third-party package can teach polyxios a forty-fifth format. Two functions and an entry point - no fork, no pull request, no restart.
from polyxios._registry import Codec def read(path, *, lazy=False): ... def write(poly, path, **opts): ... def register(): return ".abc", Codec(read, write)
[project.entry-points."polyxios.codecs"] abc = "mypackage.abc_codec:register" # then, anywhere: mesh = px.read("model.abc") # picked up automatically