pyvista.Plotter.enable_point_picking#

Plotter.enable_point_picking(callback=None, tolerance=0.025, left_clicking=False, picker=PickerType.POINT, show_message=True, font_size=18, color='pink', point_size=10, show_point=True, use_picker=False, pickable_window=False, clear_on_no_selection=True, **kwargs)[source]#

Enable picking at points under the cursor.

Enable picking a point at the mouse location in the render view using the right mouse button. This point is saved to the .picked_point attribute on the plotter. Pass a callback that takes that point as an argument. The picked point can either be a point on the first intersecting mesh, or a point in the 3D window.

The picker choice will help determine how the point picking is performed.

Parameters:
callbackcallable(), optional

When input, calls this callable after a pick is made. The picked point is input as the first parameter to this callable.

tolerancefloat, tolerance: 0.025

Specify tolerance for performing pick operation. Tolerance is specified as fraction of rendering window size. Rendering window size is measured across diagonal. This is only valid for some choices of picker.

left_clickingbool, default: False

When True, points can be picked by clicking the left mouse button. Default is to use the right mouse button.

pickerstr | 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.

show_messagebool | str, default: True

Show the message about how to use the point picking tool. If this is a string, that will be the message shown.

font_sizeint, default: 18

Sets the size of the message.

colorColorLike, default: “pink”

The color of the selected mesh when shown.

point_sizeint, default: 10

Size of picked points if show_point is True.

show_pointbool, default: True

Show the picked point after clicking.

use_pickerbool, default: False

When True, the callback will also be passed the picker.

pickable_windowbool, default: False

When True and the chosen picker supports it, points in the 3D window are pickable.

clear_on_no_selectionbool, default: True

Clear the selections when no point is selected.

**kwargsdict, optional

All remaining keyword arguments are used to control how the picked point is interactively displayed.

Examples

Enable point picking with a custom message.

>>> import pyvista as pv
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(pv.Sphere())
>>> _ = pl.add_mesh(pv.Cube(), pickable=False)
>>> pl.enable_point_picking(show_message='Pick a point')

See Picking points on a mesh for a full example using this method.

../../../_images/pyvista-Plotter-enable_point_picking-1_00_00.png