Skip to content

write_vtk builtin

write_vtk(path, data, *, ascii=False)

Writes a PointSet, Polylines, Mesh or BlockModel as a VTK XML file.

Parameters:

Name Type Description Default
path str or Path

The .vtp, .vtu or .vti file; its extension picks the format.

required
data (PointSet, Polylines, Mesh or BlockModel)

Points become vertex cells with their columns as point data. Each polyline part becomes a polyline cell, closed parts repeating their first point, with the feature columns and a feature index as cell data. A mesh writes its triangles with vertex columns as point data and face columns as cell data. A BlockModel goes to .vti as image data (regular or masked, its rotation as Direction, absent cells hidden by vtkGhostType) or to .vtu as one hexahedron per row (any layout), its columns as cell data. Numeric and bool columns are written, float32 as Float32 and the rest as Float64; a column with nulls writes them as NaN plus a UInt8 <name>_valid array.

required
ascii bool

Write ASCII arrays instead of appended raw binary.

False

Raises:

Type Description
InvalidInput

For text columns, a BlockModel in a .vtp, any other container or a sub-blocked model in a .vti, and .vtr or .vts files.

Used in