Helpers#

The pyvista module contains several functions to simplify the creation and manipulation of meshes or interfacing with VTK datasets.

See Utilities for the full API reference of all utility functions organized by category.

Mesh Creation#

wrap(dataset, *[, validate])

Wrap any given VTK data object to its appropriate PyVista data object.

make_tri_mesh(points, faces)

Construct a pyvista.PolyData mesh using points and faces arrays.

lines_from_points(points[, close])

Make a connected line set given an array of points.

line_segments_from_points(points)

Generate non-connected line segments from points.

vector_poly_data(orig, vec)

Create a pyvista.PolyData object composed of vectors.

vtk_points(points[, deep, force_float, ...])

Convert numpy array or array-like to a vtkPoints object.

Mesh Operations#

merge(datasets[, merge_points, ...])

Merge several datasets.

translate(surf[, center, direction])

Translate and orient a mesh to a new center and direction.

generate_plane(normal, origin)

Return a vtkPlane.

fit_plane_to_points(points[, return_meta, ...])

Fit a plane to points using its principal_axes().

fit_line_to_points(points, *[, resolution, ...])

Fit a line to points using its principal_axes().

Array Utilities#

convert_array(arr[, name, deep, array_type])

Convert a NumPy array to a vtkDataArray or vice versa.

sample_function(function[, bounds, dim, ...])

Sample an implicit function over a structured point set.

perlin_noise(amplitude, freq, phase)

Return the implicit function that implements Perlin noise.

Global Configuration#

class Config[source]#

PyVista core configuration.

Holds process-wide settings that affect pyvista.core behavior. The singleton instance is exposed as pyvista.global_config. This is the sibling of pyvista.global_theme for plotting (rendering) settings.

Examples

Disable the default array-length check performed by pyvista.wrap():

>>> import pyvista as pv
>>> pv.global_config.validate_on_wrap = False
>>> pv.global_config.validate_on_wrap = True  # restore default
property show_vtk_api: bool[source]#

Return or set whether VTK-inherited attributes appear in dir().

When False (the default), attributes inherited from VTK base classes are hidden from dir() and tab-completion on PyVista objects that wrap VTK types (data objects, Renderer, Actor, Property, etc.). This keeps the public surface curated for data-science IDEs such as Positron’s Variables pane and VS Code’s Jupyter extension, and for IPython / Jupyter tab-completion. VTK methods remain fully callable regardless of this setting.

When True, the full VTK API is enumerated alongside the PyVista API, which is useful for VTK developers who want to discover the raw VTK method surface via introspection.

Warning

This option requires runtime inspection and does not work with all developer tools, e.g. it has no effect when using PyCharm. This is because it relies on calling the object’s __dir__ method for generating auto-completion suggestions. Tools like PyCharm that only use static analysis for auto-completion are therefore unaffected.

Notes

The snake_case VTK aliases (number_of_points, deep_copy, …) are controlled separately by pyvista.vtk_snake_case(). When snake_case is not 'allow' (the default), those names are hidden from dir() regardless of this setting, because accessing them would already raise PyVistaAttributeError. Enabling snake_case surfaces the snake_case names in dir(); show_vtk_api only controls the CamelCase VTK API.

Added in version 0.48.

Examples

>>> import pyvista as pv
>>> pv.global_config.show_vtk_api
False
>>> pv.global_config.show_vtk_api = True
>>> pv.global_config.show_vtk_api = False  # restore default
property validate_on_wrap: bool[source]#

Return or set whether pyvista.wrap() validates data arrays.

When True (the default), pyvista.wrap() performs a cheap array-length sanity check on every VTK object it wraps and emits a InvalidMeshWarning if any point or cell data array has a tuple count that does not match the dataset’s point or cell count. Set to False to skip this check globally when the cost matters in tight loops and the caller trusts their inputs.

Notes

Per-call control is also available via the validate keyword on pyvista.wrap(), pyvista.read(), and pyvista.BaseReader.read(). The per-call keyword takes precedence; this global setting is consulted only when the per-call keyword is left at its default None.

Added in version 0.48.

Examples

>>> import pyvista as pv
>>> pv.global_config.validate_on_wrap
True
>>> pv.global_config.validate_on_wrap = False
>>> pv.global_config.validate_on_wrap = True  # restore default
class InvalidMeshWarning[source]#

Warning for invalid mesh properties.

Added in version 0.47.