# vtkPropPicker not working in Java wrapper after upgrade to 8.2.0

**URL:** <https://discourse.vtk.org/t/vtkproppicker-not-working-in-java-wrapper-after-upgrade-to-8-2-0/2121>\
**Category:** Development\
**Created:** [November 21, 2019, 2:38pm UTC](https://discourse.vtk.org/t/vtkproppicker-not-working-in-java-wrapper-after-upgrade-to-8-2-0/2121 "2019-11-21T14:38:56Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mat127](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mat127/32/255_2.png) [@mat127](https://discourse.vtk.org/u/mat127)\
**Post date:** [November 21, 2019, 2:38pm UTC](https://discourse.vtk.org/t/vtkproppicker-not-working-in-java-wrapper-after-upgrade-to-8-2-0/2121/1 "2019-11-21T14:38:56Z")

</div>

Hi,

I use the VTK library through the Java wrapper. After upgrading to 8.2.0 my code using the `vtkPropPicker` does not work any more (in 8.1.1 was ok).

The renderer where I do the picking contains a `vtkAssembly` containing several `vtkActor`s representing `vtkPolyData`. For picking I use the following code:

```
public vtkAssemblyPath pickPath(final double x, final double y) {
    if(this.picker.Pick(x, y, 0.0, this.renderer) == 0)
        return null;
    return this.picker.GetPath();
}

```

For (x,y) where no actor is present the `Pick()` method returns corretly 0. But in case that `Pick()!=0` the `GetPath()` returns always path pointing to the same `vtkActor` regardless which one is under the provided location (x,y).

What could be the problem in this case? Is the `vtkPropPicker` supported in Java wrapper?

Petr

---

<div class="post-metadata">

**Author:** ![mat127](https://discourse.vtk.org/user_avatar/discourse.vtk.org/mat127/32/255_2.png) [@mat127](https://discourse.vtk.org/u/mat127)\
**Post date:** [December 16, 2019, 9:00am UTC](https://discourse.vtk.org/t/vtkproppicker-not-working-in-java-wrapper-after-upgrade-to-8-2-0/2121/2 "2019-12-16T09:00:50Z")

</div>

Hello again,

even nobody responded I would like to share with you what did I learned about the issue so far.

After some investigation I realized that the problem is the `vtkAssemblyProp` containing the `vtkActor`s I want to pick. In case that renderer in which I do the picking contains the actors directly (not nested under any `vtkPropAssembly`) everything is fine.

To demonstrate the issue and eliminate any Java related problems I took the original [HighlightPickedActor](https://lorensen.github.io/VTKExamples/site/Cxx/Picking/HighlightPickedActor) example and modified it slightly:

> **[mat127/vtk-pick-demo](https://github.com/mat127/vtk-pick-demo)**
>
> Contribute to mat127/vtk-pick-demo development by creating an account on GitHub.

This example enables you to pick by the left mouse click any of several sphere actors added directly into the renderer. I added the same number of cube actors that are nested within single vtkPropAssembly that is added into the same renderer as the spheres. Left click on any sphere works fine. But left click on cube highlights always the same cube.

In the previous version(s) 8.1.x `vtkPropPicker::GetPath` returned correctly the path to the actor (prop) under the coordinates provided to the `vtkPropPicker::Pick` method. In the 8.2.0 this behavior is gone. Is it a bug? Or do I use the picking API wrong way?

The good news is that I have found a workaround: When the following method is used

`int vtkPropPicker::PickProp(double selectionX, double selectionY, vtkRenderer *renderer, vtkPropCollection *pickfrom)`

and actors nested in the `vtkPropAssembly` are passed as the `pickfrom` collection one can pick nested actors again. Uncomment the line 188 in the provided example [HighlightPickedActor.cxx](https://github.com/mat127/vtk-pick-demo/blob/master/HighlightPickedActor.cxx) to see it in action. But of course spheres cannot picked now.

I will really appreciate a lot any comments on my usage of the picking API to realize whether it is right or wrong.

Petr
