pyvista convert

pyvista convert#

Command-line interface for converting one or more mesh files to another format.

Using pyvista convert is similar to calling read() and save() together in Python.

Examples#

Note

To run the examples yourself locally, first change directory to pyvista/examples, e.g.

cd $(python -c "import pyvista.examples, pathlib; print(pathlib.Path(pyvista.examples.__file__).parent)")

Convert a PLY file (.ply) into a VTK XML PolyData file (.vtp).

$ pyvista convert ant.ply ant_converted.vtp
Saved: ant_converted.vtp

Keep the filename the same and specify the output extension only.

$ pyvista convert ant.ply .vtp
Saved: ant.vtp

Use wildcard patterns to convert multiple files at once into an explicit output directory.

$ pyvista convert *.ply output/.vtp

Converting ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0/40:00:00 < -:--:--
Converting sphere.ply ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 4/40:00:00 < 0:00:00
Saved 4 files to: output/

API Reference#

Show the output from pyvista convert --help.

$ pyvista convert --help
Usage: pyvista convert PATH-IN [PATH-IN...] PATH-OUT

Convert one or more mesh files to another format.                               

One or more inputs may be supplied, and glob patterns are expanded. When        
multiple inputs are given, the output must be an extension-only spec (.xyz or   
dir/.xyz) so each input's stem is reused. A bare .xyz writes the output adjacent
to each input; dir/.xyz writes into the given dir.                              

MultiBlock files (.vtm/.vtmb) are paired on disk with a sibling sidecar         
directory (e.g. parent.vtm -> parent/parent_0.vtp). Pass the parent .vtm        
directly to convert a MultiBlock as a single output; a recursive glob like **/* 
may also pick up the sidecar children. When both a parent and its sidecar       
children appear in the input list the children are dropped automatically to     
preserve the 1:1 input/output mapping.

╭─ Arguments ──────────────────────────────────────────────────────────────────╮
│ Option   Default  Description                                                │
│ * PATHS  -        One or more input paths followed by the output spec.       │
│                   Inputs may include glob patterns (e.g. *.vtu) and must be  │
│                   readable with pyvista.read. The final token is the output: │
│                   a full filename (bar.xyz) when converting a single input,  │
│                   or an extension-only spec (.xyz or dir/.xyz) which reuses  │
│                   each input stem. A bare .xyz writes adjacent to each       │
│                   input; dir/.xyz writes into dir/.                          │
╰──────────────────────────────────────────────────────────────────────────────╯
╭─ Parameters ─────────────────────────────────────────────────────────────────╮
│ Option                Default  Description                                   │
│ --resolve-collisions  False    When multiple inputs resolve to the same      │
│                                output path, automatically rename colliding   │
│                                outputs by appending _1, _2, etc. to the      │
│                                stem. Without this flag, collisions are an    │
│                                error.                                        │
│ --skip-unreadable     False    Skip any paths that are not readable instead  │
│                                of raising an error.                          │
╰──────────────────────────────────────────────────────────────────────────────╯