# Is there any way to to determine which actor is clicked when using vtkCellPicker to pick a assembly.

**URL:** https://discourse.vtk.org/t/is-there-any-way-to-to-determine-which-actor-is-clicked-when-using-vtkcellpicker-to-pick-a-assembly/11192
**Category:** Support
**Created:** [April 12, 2023, 3:36pm UTC](https://discourse.vtk.org/t/is-there-any-way-to-to-determine-which-actor-is-clicked-when-using-vtkcellpicker-to-pick-a-assembly/11192 "2023-04-12T15:36:58Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![AlexLuya](https://discourse.vtk.org/user_avatar/discourse.vtk.org/alexluya/32/4036_2.png) [@AlexLuya](https://discourse.vtk.org/u/AlexLuya)
#### Post date: [April 12, 2023, 3:36pm UTC](https://discourse.vtk.org/t/is-there-any-way-to-to-determine-which-actor-is-clicked-when-using-vtkcellpicker-to-pick-a-assembly/11192/1 "2023-04-12T15:36:58Z")

</div>

Hello,for some reasons I have to put a bunch of actors into an assembly and at the same I have to highlight picked clicked.But

`vtkCellPicker->GetViewProp()`

returns a vtkAssembly?My questions are:

1, Is there any way to to determine which actor is clicked within this assembly?

If not,I found vtkCellPicker-\>GetCellId() will return a cell id,

2, Is there any way to detemine the actor that this cell id belongs to?

---

<div class="post-metadata">

### Author: ![CharInt0](https://discourse.vtk.org/user_avatar/discourse.vtk.org/charint0/32/2983_2.png) [@CharInt0](https://discourse.vtk.org/u/CharInt0)
#### Post date: [April 20, 2023, 2:35pm UTC](https://discourse.vtk.org/t/is-there-any-way-to-to-determine-which-actor-is-clicked-when-using-vtkcellpicker-to-pick-a-assembly/11192/2 "2023-04-20T14:35:16Z")

</div>

I am not an expert. I am not sure if you have already tried looking into vtkAssemblyPath. Here is an excerpt from “The VTK User’s Guide” 11th Edition pag 59:

> The class vtkAbstractProp-  
> Picker is another direct subclass of vtkAbstractPicker. It defines an API for pickers that can pick an  
> instance of vtkProp. There are several convenience methods in this class to allow querying for the  
> return type of a pick.  
> • GetProp() — Return the instance of vtkProp that was picked. If anything at all was picked,  
> then this method will return a pointer to the instance of vtkProp, otherwise NULL is returned.  
> • GetProp3D() — If an instance of vtkProp3D was picked, return a pointer to the instance of  
> vtkProp3D.  
> • GetActor2D() — If an instance of vtkActor2D was picked, return a pointer to the instance of  
> vtkActor2D.  
> • GetActor() — If an instance of vtkActor was picked, return a pointer to the instance of  
> vtkActor.  
> 60 The Basics  
> • GetVolume() — If an instance of vtkVolume was picked, return a pointer to the instance of  
> vtkVolume.  
> • **GetAssembly()** — If an instance of vtkAssembly was picked, return a pointer to the instance\*  
> _of vtkAssembly._  
> • **GetPropAssembly()** — If an instance of vtkPropAssembly was picked, return a pointer to the\*  
> _instance of vtkPropAssembly._  
> A word of caution about these methods. _The class (and its subclass) return information about the top_  
> _level of the assembly path that was picked. So if you have an assembly whose top level is of type_  
> _vtkAssembly, and whose leaf node is of type vtkActor, the method GetAssembly() will return a_  
> _pointer to the instance of vtkAssembly, while the GetActor() method will return a NULL pointer (i.e.,_  
> \*no vtkActor). **If you have a complex scene that includes assemblies, actors, and other types of props,**  
> **the safest course to take is to use the GetProp() method to determine whether anything at all was**  
> **picked, and then use GetPath()**

at pag 61:

> vtkAssemblyPath  
> An understanding of the class vtkAssemblyPath is essential if you are to perform picking in a scene  
> with different types of vtkProp’s, especially if the scene contains instances of vtkAssembly. vtkAs-  
> semblyPath is simply an ordered list of vtkAssemblyNode’s, where each node contains a pointer to a  
> vtkProp, as well as an optional vtkMatrix4x4. The order of the list is important: the start of the list  
> represents the root, or top level node in an assembly hierarchy, while the end of the list represents a  
> leaf node in an assembly hierarchy. The ordering of the nodes also affects the associated matrix. Each  
> matrix is a concatenation of the node’s vtkProp’s matrix with the previous matrix in the list. Thus, for  
> a given vtkAssemblyNode, the associated vtkMatrix4x4 represents the position and orientation of the  
> vtkProp (assuming that the vtkProp is initially untransformed).

and most importantly read here (from vtkAbstractPropPicker Class Reference):

> [vtkAbstractPropPicker](https://vtk.org/doc/release/5.6/html/a00094.html) is an abstract superclass for pickers that can pick an instance of [vtkProp](https://vtk.org/doc/release/5.6/html/a01508.html). Some pickers, like [vtkWorldPointPicker](https://vtk.org/doc/release/5.6/html/a02182.html) (not a subclass of this class), cannot identify the prop that is picked. Subclasses of [vtkAbstractPropPicker](https://vtk.org/doc/release/5.6/html/a00094.html) return a prop in the form of a [vtkAssemblyPath](https://vtk.org/doc/release/5.6/html/a00158.html) when a pick is invoked. Note that an [vtkAssemblyPath](https://vtk.org/doc/release/5.6/html/a00158.html) contain a list of vtkAssemblyNodes, each of which in turn contains a reference to a [vtkProp](https://vtk.org/doc/release/5.6/html/a01508.html) and a 4x4 transformation matrix. **The path fully describes the entire pick path, so you can pick assemblies or portions of assemblies, or just grab the tail end of the** [vtkAssemblyPath](https://vtk.org/doc/release/5.6/html/a00158.html) **(which is the picked prop).**

---

<div class="post-metadata">

### Author: ![cangsun](https://discourse.vtk.org/user_avatar/discourse.vtk.org/cangsun/32/8639_2.png) [@cangsun](https://discourse.vtk.org/u/cangsun)
#### Post date: [March 15, 2024, 1:33am UTC](https://discourse.vtk.org/t/is-there-any-way-to-to-determine-which-actor-is-clicked-when-using-vtkcellpicker-to-pick-a-assembly/11192/3 "2024-03-15T01:33:08Z")

</div>

Thanks, with your tips I found the solution：

auto assemblyPath = m\_cellPicker-\>GetPath();  
if (!assemblyPath)  
{  
return;  
}  
auto actor = vtkActor::SafeDownCast(assemblyPath-\>GetLastNode()-\>GetViewProp());  
std::cout \<\< "actor = " \<\< actor \<\< std::endl;
