# Naming vtkActors

**URL:** https://discourse.vtk.org/t/naming-vtkactors/9958
**Category:** Support
**Created:** [November 25, 2022, 9:02pm UTC](https://discourse.vtk.org/t/naming-vtkactors/9958 "2022-11-25T21:02:24Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [November 25, 2022, 9:02pm UTC](https://discourse.vtk.org/t/naming-vtkactors/9958/1 "2022-11-25T21:02:24Z")

</div>

I suspect that this question / concern is addressed somewhere in an example (or reference page) that I haven’t found.

I have a number of actors in my program. I would like to be able to set a name or label for them when I create them so that I can distinguish them from each other when I loop over them in a vtkActorCollection (in order to change properties for some of them).

It’s possible I’m not thinking about this correctly. How can I accomplish my goal of knowing which actor is which?

---

<div class="post-metadata">

### Author: ![will.schroeder](https://discourse.vtk.org/user_avatar/discourse.vtk.org/will.schroeder/32/233_2.png) [@will.schroeder](https://discourse.vtk.org/u/will.schroeder)
#### Post date: [November 26, 2022, 11:46am UTC](https://discourse.vtk.org/t/naming-vtkactors/9958/2 "2022-11-26T11:46:01Z")

</div>

IMO this is headed in the area of application logic. Typically I’ve used a map or hash to create a lookup between the actor’s address/pointer and additional metadata (such as name) that I’d like to associate with the actor. And of course you can create a two-way data structure so you can go from name to address etc.

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [November 26, 2022, 2:11pm UTC](https://discourse.vtk.org/t/naming-vtkactors/9958/3 "2022-11-26T14:11:06Z")

</div>

In VTK 9.2, you can use [SetObjectName()/GetObjectName()](https://vtk.org/doc/nightly/html/classvtkObject.html#ad8d3b69403d91d88295d423f7539e0a6) to label your actors.

If you’re using Python, you can add custom attributes to VTK objects:

```python
a = vtk.vtkActor()
a.name = 'Kevin'

```

---

<div class="post-metadata">

### Author: ![BlueKnight7](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/838e76/32.png) [@BlueKnight7](https://discourse.vtk.org/u/BlueKnight7)
#### Post date: [November 27, 2022, 8:06pm UTC](https://discourse.vtk.org/t/naming-vtkactors/9958/4 "2022-11-27T20:06:54Z")

</div>

I use C++ and not Python. This is with Vtk 9.1

I see from the vtkActor reference page that vtkActor inherits from vtkObject. However, when I try to use SetObjectName, I receive a compile message that “class vtkActor has no member named SetObject Name”.

e.g.

vtkNew myActor;  
myActor-\>SetObjectName(“AName”);

I have included both vtkObject.h and vtkActor.h in my header file.

Okay. I must be doing something stupid here. Any ideas as to why this fails for me?

---

<div class="post-metadata">

### Author: ![dgobbi](https://discourse.vtk.org/user_avatar/discourse.vtk.org/dgobbi/32/18_2.png) [@dgobbi](https://discourse.vtk.org/u/dgobbi)
#### Post date: [November 27, 2022, 8:23pm UTC](https://discourse.vtk.org/t/naming-vtkactors/9958/5 "2022-11-27T20:23:14Z")

</div>

As you said, you’re using VTK 9.1. The SetObjectName() method was added in VTK 9.2.
