<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr">Hello,<div>I have multiple actors in the scene, and I have re-implemented the vtkInteractorStyleTrackballCamera to capture the click event on them (modified  <a href="https://lorensen.github.io/VTKExamples/site/Python/Interaction/HighlightPickedActor/">https://lorensen.github.io/VTKExamples/site/Python/Interaction/HighlightPickedActor/</a>)</div><div>In the click event, I want to know which actor has been clicked to do so I am adding vtkInformationStringKey to every actor. But at the click event, I am not able to retrieve it back.</div><div>Please let me know what am I missing? Or what am I doing wrong?</div><div><br></div><div>Here is my code: </div><div>```</div><div><div>import vtk</div><div><br></div><div>NUMBER_OF_SPHERES = 10</div><div><br></div><div><br></div><div>class MouseInteractorHighLightActor(vtk.vtkInteractorStyleTrackballCamera):</div><div><br></div><div>    def __init__(self, parent=None):</div><div>        self.AddObserver("LeftButtonPressEvent", self.leftButtonPressEvent)</div><div><br></div><div>        self.LastPickedActor = None</div><div>        self.LastPickedProperty = vtk.vtkProperty()</div><div><br></div><div>    def leftButtonPressEvent(self, obj, event):</div><div>        clickPos = self.GetInteractor().GetEventPosition()</div><div><br></div><div>        picker = vtk.vtkPropPicker()</div><div>        picker.Pick(clickPos[0], clickPos[1], 0, self.GetDefaultRenderer())</div><div><br></div><div>        # get the new</div><div>        self.NewPickedActor = picker.GetActor()</div><div><br></div><div>        # If something was selected</div><div>        if self.NewPickedActor:</div><div>            # get the information from the new Actor</div><div>            info = self.NewPickedActor.GetProperty().GetInformation()</div><div>            # prepare the key</div><div>            key = vtk.vtkInformationStringKey.MakeKey("CPHY_ID", "vtkActor")</div><div>            # get the value for the key</div><div>            id = info.Get(key)</div><div>            print("Id is : ")</div><div>            print(id)</div><div><br></div><div>            # If we picked something before, reset its property</div><div>            if self.LastPickedActor:</div><div>                self.LastPickedActor.GetProperty().DeepCopy(self.LastPickedProperty)</div><div><br></div><div>            # Save the property of the picked actor so that we can</div><div>            # restore it next time</div><div>            self.LastPickedProperty.DeepCopy(self.NewPickedActor.GetProperty())</div><div>            # Highlight the picked actor by changing its properties</div><div>            self.NewPickedActor.GetProperty().SetColor(1.0, 0.0, 0.0)</div><div>            self.NewPickedActor.GetProperty().SetDiffuse(1.0)</div><div>            self.NewPickedActor.GetProperty().SetSpecular(0.0)</div><div><br></div><div>            # save the last picked actor</div><div>            self.LastPickedActor = self.NewPickedActor</div><div><br></div><div>        self.OnLeftButtonDown()</div><div>        return</div><div><br></div><div><br></div><div># A renderer and render window</div><div>renderer = vtk.vtkRenderer()</div><div>renderer.SetBackground(.3, .4, .5)</div><div><br></div><div><br></div><div>renwin = vtk.vtkRenderWindow()</div><div>renwin.AddRenderer(renderer)</div><div><br></div><div># An interactor</div><div>interactor = vtk.vtkRenderWindowInteractor()</div><div>interactor.SetRenderWindow(renwin)</div><div><br></div><div># add the custom style</div><div>style = MouseInteractorHighLightActor()</div><div>style.SetDefaultRenderer(renderer)</div><div>interactor.SetInteractorStyle(style)</div><div><br></div><div># Add spheres to play with</div><div>for i in range(NUMBER_OF_SPHERES):</div><div>    source = vtk.vtkSphereSource()</div><div><br></div><div>    # random position and radius</div><div>    x = vtk.vtkMath.Random(-5, 5)</div><div>    y = vtk.vtkMath.Random(-5, 5)</div><div>    z = vtk.vtkMath.Random(-5, 5)</div><div>    radius = vtk.vtkMath.Random(.5, 1.0)</div><div><br></div><div>    source.SetRadius(radius)</div><div>    source.SetCenter(x, y, z)</div><div>    source.SetPhiResolution(11)</div><div>    source.SetThetaResolution(21)</div><div><br></div><div>    mapper = vtk.vtkPolyDataMapper()</div><div>    mapper.SetInputConnection(source.GetOutputPort())</div><div>    actor = vtk.vtkActor()</div><div>    actor.SetMapper(mapper)</div><div><br></div><div>    r = vtk.vtkMath.Random(.4, 1.0)</div><div>    g = vtk.vtkMath.Random(.4, 1.0)</div><div>    b = vtk.vtkMath.Random(.4, 1.0)</div><div>    actor.GetProperty().SetDiffuseColor(r, g, b)</div><div>    actor.GetProperty().SetDiffuse(.8)</div><div>    actor.GetProperty().SetSpecular(.5)</div><div>    actor.GetProperty().SetSpecularColor(1.0, 1.0, 1.0)</div><div>    actor.GetProperty().SetSpecularPower(30.0)</div><div><br></div><div>    info = actor.GetProperty().GetInformation()</div><div>    key = vtk.vtkInformationStringKey.MakeKey("CPHY_ID", "vtkActor")</div><div>    info.Set(key, "SPH_"+str(i))</div><div>    #actor.GetProperty().SetInformation(info)</div><div><br></div><div>    renderer.AddActor(actor)</div><div><br></div><div>for i in range(NUMBER_OF_SPHERES):</div><div>    source = vtk.vtkConeSource()</div><div><br></div><div>    # random position and radius</div><div>    x = vtk.vtkMath.Random(-8, 5)</div><div>    y = vtk.vtkMath.Random(-8, 5)</div><div>    z = vtk.vtkMath.Random(-8, 5)</div><div>    radius = vtk.vtkMath.Random(.5, 1.0)</div><div><br></div><div>    angle = vtk.vtkMath.Random(5, 10)</div><div>    source.SetAngle(angle)</div><div>    source.SetRadius(radius)</div><div>    source.SetCenter(x, y, z)</div><div>    # source.SetPhiResolution(11)</div><div>    # source.SetThetaResolution(21)</div><div><br></div><div>    mapper = vtk.vtkPolyDataMapper()</div><div>    mapper.SetInputConnection(source.GetOutputPort())</div><div>    actor = vtk.vtkActor()</div><div>    actor.SetMapper(mapper)</div><div><br></div><div>    r = vtk.vtkMath.Random(.4, 1.0)</div><div>    g = vtk.vtkMath.Random(.4, 1.0)</div><div>    b = vtk.vtkMath.Random(.4, 1.0)</div><div>    actor.GetProperty().SetDiffuseColor(r, g, b)</div><div>    actor.GetProperty().SetDiffuse(.8)</div><div>    actor.GetProperty().SetSpecular(.5)</div><div>    actor.GetProperty().SetSpecularColor(1.0, 1.0, 1.0)</div><div>    actor.GetProperty().SetSpecularPower(30.0)</div><div><br></div><div>    info = actor.GetProperty().GetInformation()</div><div>    key = vtk.vtkInformationStringKey.MakeKey("CPHY_ID", "vtkActor")</div><div>    info.Set(key, "CON_"+str(i))</div><div>    #actor.GetProperty().SetInformation(info)</div><div>    renderer.AddActor(actor)</div><div><br></div><div># Start</div><div>interactor.Initialize()</div><div>interactor.Start()</div><div>```</div><div><br></div><div>Regards,</div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div>Abhishek<br><a href="http://zeroth.me">http://zeroth.me</a><br><br></div></div></div></div></div></div></div></div></div>