read_pickle#
- read_pickle(filename: str | Path) DataObject[source]#
Load a pickled mesh from file.
- Parameters:
- filename
str The path of the pickled mesh to read.
- filename
- Returns:
pyvista.DataObjectUnpickled mesh.
Examples
Save a pickled mesh and read it.
>>> import pyvista as pv >>> from pyvista import examples >>> mesh = examples.load_ant() >>> pv.save_pickle('ant.pkl', mesh) >>> new_mesh = pv.read_pickle('ant.pkl') >>> new_mesh PolyData (...) N Cells: 912 N Points: 486 N Strips: 0 X Bounds: -1.601e+01, 1.601e+01 Y Bounds: -9.385e+00, 9.385e+00 Z Bounds: -1.678e+01, 1.678e+01 N Arrays: 0
Unlike other file formats, custom attributes are saved with pickled meshes.
>>> pv.set_new_attribute(mesh, 'custom_attribute', 42) >>> pv.save_pickle('ant.pkl', mesh) >>> new_mesh = pv.read_pickle('ant.pkl') >>> new_mesh.custom_attribute 42