ExplicitStructuredGrid.save

Contents

ExplicitStructuredGrid.save#

ExplicitStructuredGrid.save(
filename: Path | str,
binary: bool = True,
texture: NumpyArray[np.uint8] | str | None = None,
compression: _CompressionOptions = 'zlib',
**writer_kwargs: Any,
) None[source]#

Save this VTK object to file.

Parameters:
filenamePath, str

Output file name. VTU and VTK extensions are supported.

binarybool, default: True

If True, write as binary, else ASCII.

texturenp.ndarray, str, None

Ignored argument. Kept to maintain compatibility with supertype.

compressionstr or None, default: ‘zlib’

The compression type to use when binary is True and VTK writer is of type vtkXMLWriter. This argument has no effect otherwise. Acceptable values are 'zlib', 'lz4', 'lzma', and None. None indicates no compression.

Added in version 0.47.

**writer_kwargsdict, optional

Additional keyword arguments forwarded verbatim to a custom writer registered via pyvista.register_writer(). When the target extension dispatches to a built-in VTK writer or to the pickle path, passing any extra keyword arguments raises TypeError.

Added in version 0.48.

Notes

VTK adds the 'BLOCK_I', 'BLOCK_J' and 'BLOCK_K' cell arrays. These arrays are required to restore the explicit structured grid.

Examples

>>> import pyvista as pv
>>> from pyvista import examples
>>> grid = examples.load_explicit_structured()
>>> grid = grid.hide_cells(range(80, 120))
>>> grid.save('grid.vtu')
>>> grid = pv.ExplicitStructuredGrid('grid.vtu')
>>> grid.plot(color='w', show_edges=True, show_bounds=True)
>>> grid.show_cells()
>>> grid.plot(color='w', show_edges=True, show_bounds=True)