[vtkusers] picking actor

Prabhu Ramachandran prabhu at aero.iitm.ernet.in
Thu Apr 3 12:04:10 EST 2003

>>>>> "JH" == John Hunter <jdhunter at ace.bsd.uchicago.edu> writes:

    JH> I have a class Marker that is derived from vtk.vtkActor in
    JH> python, and a scene that is populated with a number of these
    JH> markers and some other actors that I don't want to pick.  I
    JH> pick a marker with


    JH> However, when I get the string representation of the actor, it
    JH> reports itself as a vtkOpenGLActor, and does not have the
    JH> attributes of my derived class.  I need to be able to get the
    JH> instance of my derived class.  I can imagine a way to hack
    JH> this out, eg by comparing some attribute of the vtkOpenGLActor
    JH> with the instances of my Marker class (like the center, which
    JH> will be unique for my markers), but I suspect there is an
    JH> elegant, right way to do it.

That is a little surprising.  I'm way out of touch on this but the
following fragment works fine for me with VTK off CVS, Python2.2.

In [2]: import vtk
In [3]: class MyMapper(vtk.vtkPolyDataMapper):
   ...:  def test(self):
   ...:   print "MyMapper.test()"
   ...:   print self.a

In [4]: c = vtk.vtkConeSource()
In [5]: m = MyMapper ()
In [6]: m.SetInput(c.GetOutput())
In [7]: m.a = 100
In [8]: m.test()

In [9]: a = vtk.vtkActor()
In [10]: a.SetMapper(m)
In [11]: m1 = a.GetMapper ()
In [12]: m1.test()


p.s. I'm using the excellent IPython interpreter

More information about the vtkusers mailing list