pyvista.Plotter.enable_mesh_picking#
- Plotter.enable_mesh_picking(
- callback=None,
- show=True,
- show_message=True,
- style='wireframe',
- line_width=5,
- color='pink',
- font_size=18,
- left_clicking=False,
- use_actor=False,
- picker=PickerType.CELL,
- **kwargs,
Enable picking of a mesh.
- Parameters:
- callback
callable(),optional When input, calls this callable after a selection is made. The
meshis input as the first parameter to this callable.- showbool, default:
True Show the selection interactively. Best when combined with
left_clicking.- show_messagebool |
str, default:True Show the message about how to use the mesh picking tool. If this is a string, that will be the message shown.
- style
str, default: “wireframe” Visualization style of the selection. One of the following:
'surface''wireframe''points'
- line_width
float, default: 5.0 Thickness of selected mesh edges.
- color
ColorLike, default: “pink” The color of the selected mesh when shown.
- font_size
int, default: 18 Sets the font size of the message.
- left_clickingbool, default:
False When
True, meshes can be picked by clicking the left mousebutton.Note
If enabled, left-clicking will not display the bounding box around the picked point.
- use_actorbool, default:
False If True, the callback will be passed the picked actor instead of the mesh object.
- picker
str|PickerType,optional Choice of VTK picker class type:
'hardware': Uses vtkHardwarePicker which is more performant for large geometries (default).'cell': Uses vtkCellPicker.'point': Uses vtkPointPicker which will snap to points on the surface of the mesh.'volume': Uses vtkVolumePicker.
- **kwargs
dict,optional All remaining keyword arguments are used to control how the picked path is interactively displayed.
- callback
- Returns:
- vtkPropPicker
Property picker.
Examples
Add a sphere and a cube to a plot and enable mesh picking. Enable
left_clickingto immediately start picking on the left click and disable showing the box. You can still press thepkey to select meshes.>>> import pyvista as pv >>> mesh = pv.Sphere(center=(1, 0, 0)) >>> cube = pv.Cube() >>> pl = pv.Plotter() >>> _ = pl.add_mesh(mesh) >>> _ = pl.add_mesh(cube) >>> _ = pl.enable_mesh_picking()
See Picking Meshes for a full example using this method.