import pyvista as pv mesh = pv.read("model.stl")★One reader for everything — STL, OBJ, PLY, VTK/VTU/VTP, gLTF and more, via a pluggable reader registry. Returns a mesh object.from pyvista import examples mesh = examples.download_bunny() # built-in sample data★Theexamplesmodule has dozens of downloadable datasets — great for learning and reproducing docs.pip install "pyvista[all]" # + jupyter, io, imageio extrasBasepyvistacovers desktop plotting; the[all]extra adds Jupyter (trame), extra I/O, and movie export.
pv.Sphere() · pv.Cube() · pv.Cylinder() · pv.Plane() · pv.Cone()★Parametric primitives returnPolyData— handy for tests, glyphs, and scene props.cloud = pv.PolyData(points) # (N, 3) numpy -> point cloud surf = pv.PolyData(points, faces) # + connectivity -> surface★Build from NumPy.pointsis an (N,3) array;facesis a VTK-style connectivity array.pv.wrap(arr)wraps NumPy/VTK objects.grid = pv.ImageData(dimensions=(10, 10, 10)) # uniform grid pv.StructuredGrid(x, y, z) · pv.UnstructuredGrid(...)Gridded types for volumes/FE data. Note:ImageDatais the current name for the oldUniformGrid.
mesh.point_data["temp"] = temps # per-vertex (len == n_points) mesh.cell_data["region"] = ids # per-cell (len == n_cells)★Attach NumPy arrays to points or cells. Length must matchn_points/n_cellsrespectively.mesh["temp"] = temps # shortcut (infers point/cell by length) mesh.set_active_scalars("temp")★Themesh["name"]shortcut assigns by length; the active scalars are what plots/filters use by default.mesh.points · mesh.n_points · mesh.n_cells · mesh.bounds · mesh.centerGeometry introspection.mesh.pointsis a live (N,3) NumPy view — edit it to move vertices.