pyvista.Cube#
- Cube(
- center: VectorLike[float] = (0.0, 0.0, 0.0),
- x_length: float = 1.0,
- y_length: float = 1.0,
- z_length: float = 1.0,
- bounds: VectorLike[float] | None = None,
- clean: bool = True,
- point_dtype: str = 'float32',
Create a cube.
It’s possible to specify either the center and side lengths or just the bounds of the cube. If
boundsare given, all other arguments are ignored.Changed in version 0.33.0: The cube is created using vtkCubeSource. For compatibility with
pyvista.PlatonicSolid(), face indices are also added as cell data. For full compatibility withPlatonicSolid(), one has to usex_length = y_length = z_length = 2 * radius / 3**0.5. The cube points are also cleaned by default now, leaving only the 8 corners and a watertight (manifold) mesh.- Parameters:
- centersequence[
float], default: (0.0, 0.0, 0.0) Center in
[x, y, z].- x_length
float, default: 1.0 Length of the cube in the x-direction.
- y_length
float, default: 1.0 Length of the cube in the y-direction.
- z_length
float, default: 1.0 Length of the cube in the z-direction.
- boundssequence[
float],optional Specify the bounding box of the cube. If given, all other size arguments are ignored.
(x_min, x_max, y_min, y_max, z_min, z_max).- cleanbool, default:
True Whether to clean the raw points of the mesh, making the cube manifold. Note that this will degrade the texture coordinates that come with the mesh, so if you plan to map a texture on the cube, consider setting this to
False.Added in version 0.33.0.
- point_dtype
str, default: ‘float32’ Set the desired output point types. It must be either ‘float32’ or ‘float64’.
Added in version 0.44.0.
- centersequence[
- Returns:
pyvista.PolyDataMesh of the cube.
Examples
Create a default cube.
>>> import pyvista as pv >>> mesh = pv.Cube() >>> mesh.plot(show_edges=True, line_width=5)