pyvista.DataObject.save

pyvista.DataObject.save#

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

Save this vtk object to file.

ImageData File Formats

File Format

File Extension(s)

read()

save()

BMP

.bmp

DEM

.dem

DICOM

.dcm, .img

GaussianCube

.cube

GESigna

.mr

GIF

.gif

HDF

.hdf, .vtkhdf

HDR

.hdr

JPEG

.jpeg, .jpg

Meta

.mha, .mhd

MINC

.mnc

NIFTI

.nii, .nii.gz

NRRD

.nhdr, .nrrd

PNG

.png

PNM

.pnm

SegY

.segy, .sgy

SLC

.slc

TIFF

.tif, .tiff

VTK

.vtk

VTKP

.pvtk

XML

.vti

XMLP

.pvti

RectilinearGrid File Formats

File Format

File Extension(s)

read()

save()

VTK

.vtk

VTKP

.pvtk

Xdmf

.xdmf

XMLP

.pvtr

XML

.vtr

StructuredGrid File Formats

File Format

File Extension(s)

read()

save()

SegY

.segy, .sgy

VTK

.vtk

VTKP

.pvtk

Xdmf

.xdmf

XML

.vts

PolyData File Formats

File Format

File Extension(s)

read()

save()

BinaryMarchingCubes

.tri

BYU

.g

Facet

.facet

GaussianCube

.cube

HDF

.hdf, .vtkhdf

OBJ

.obj

Particle

.raw

PDB

.pdb

PLY

.ply

PTS

.pts

STL

.stl

VTK

.vtk

VTKP

.pvtk

XML

.vtp

Houdini

.geo

IV

.iv

UnstructuredGrid File Formats

File Format

File Extension(s)

read()

save()

AVSucd

.inp

Fluent

.cas

Gambit

.neu

HDF

.hdf, .vtkhdf

MFIX

.res

Nek5000

.nek5000

ProStar

.vrt

VTK

.vtk

VTKP

.pvtk

Xdmf

.xdmf

XMLP

.pvtu

XML

.vtu

MultiBlock File Formats

File Format

File Extension(s)

read()

save()

CGNS

.cgns

EnSight

.case

ExodusII

.e, .ex2, .exii, .exo

FLUENTCFF

.h5

GLTF

.glb, .gltf

HDF

.hdf, .vtkhdf

Plot3DMeta

.p3d

POpenFOAM

.foam

PVD

.pvd

Tecplot

.dat

Xdmf

.xdmf

XML

.vtm, .vtmb

PartitionedDataSet File Formats

File Format

File Extension(s)

read()

save()

HDF

.hdf, .vtkhdf

XML

.vtpd

Added in version 0.45: Support saving pickled meshes

Parameters:
filenamestr, pathlib.Path

Filename of output file. Writer type is inferred from the extension of the filename.

binarybool, default: True

If True, write as binary. Otherwise, write as ASCII.

texturestr, np.ndarray, optional

Write a single texture array to file when using a PLY file. Texture array must be a 3 or 4 component array with the datatype np.uint8. Array may be a cell array or a point array, and may also be a string if the array already exists in the PolyData.

If a string is provided, the texture array will be saved to disk as that name. If an array is provided, the texture array will be saved as 'RGBA'

Note

This feature is only available when saving PLY files.

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.

See also

pyvista.read

Notes

Binary files write much faster than ASCII and have a smaller file size.