pyvista_js.PolyData.tube

Contents

pyvista_js.PolyData.tube#

PolyData.tube(*, radius: float = 0.5, n_sides: int = 20, capping: bool = True) PolyData#

Generate a tube around a line polydata.

This filter creates a tube representation around lines in the mesh by sweeping a polygonal cross-section along each line. It mirrors the PyVista tube filter API and is backed by vtk.js’s vtkTubeFilter.

Note

This filter is intended for use with line-based polydata (such as the output of Line). It uses vtk.js’s vtkTubeFilter, which generates a tube by sweeping a circle with n_sides sides along the line segments.

Parameters:
  • radius (float, optional) – The radius of the tube. Default is 0.5.

  • n_sides (int, optional) – The number of sides for the tube cross-section. Higher values produce smoother tubes. Default is 20.

  • capping (bool, optional) – Whether to cap the ends of the tube. Default is True.

Returns:

A new mesh representing the tube.

Return type:

PolyData

Examples

>>> import pyvista_js as pv
>>> line = pv.Line()
>>> tube = line.tube(radius=0.05, n_sides=20)
>>> isinstance(tube, pv.PolyData)
True

Render the tube:

>>> tube.plot()