[vtkusers] renderer.GetActors() returning 3d actors, but not 2d actors.

David Gobbi david.gobbi at gmail.com
Fri Sep 12 20:20:43 EDT 2014


Use GetViewProps() and use IsA() to check the type of each prop.

On Fri, Sep 12, 2014 at 6:04 PM, Greg Schussman
<greg.schussman at gmail.com> wrote:
> Hi.
>
> I'm using python-2.6 and vtk-5.10.1.
>
> I have a renderer, to which I'm adding actors.  Some are 3d actors
> (surfaces, sets of cones), and some are 2d actors (filename text,
> scalarbar).  To add them, I'm calling:
>
>   self.renderer.AddActor(my_actor)  #  Also tried AddViewProp(my_actor)
>
> They seem to add in ok, and they do get rendered.
>
> However, based on user input, sometimes actors need to be removed and new
> ones added.  So I need to take a look at what's already there, which I do
> this way:
>
>   c = self.renderer.GetActors()
>   c.InitTraversal()
>   num_items = c.GetNumberOfItems()
>   result = []
>   for i in xrange(num_items):
>       result.append(c.GetNextActor())
>
> I notice that when I add a 3d actor and I check before/adter, the num_items
> increments as expected.
>
> However, when I add 2d actors (ScalarBar, Text), although they also render,
> when I check before/after, the num_items does not increment, and they are
> not returned in the GetActors() list.
>
> How do I find out which 2d actors are in the renderer, so that I can
> optionally remove some of them?
>
> Should I be doing something different?
>
> Thanks.
>
> Greg
>
> p.s.  I've tried calling renderer.GetActors2D(), but then when i try to call
> GetNextActor() on that, I get "AttributeError: GetNextActor".


More information about the vtkusers mailing list