[vtkusers] Copying an Assembly

Wesley Brooks wesbrooks at gmail.com
Tue Jan 29 05:45:39 EST 2008


VTK 5.0.3
Python 2.5 (r25:51908, Nov  6 2007, 15:55:44)
Fedora 7 on Linux kernel 2.6.23.12

Dear Users,

Is this the most efficient way of getting a copy of an assembly that I
can move around separately to the old assembly? I tried
vtkAssembly.ShallowCopy( anothervtkAssembly ) and it left me with a
single assembly on the screen, rather than many copies in different
positions.

self.mainAssembly  is an instance of  vtk.vtkAssembly

def ReturnShallowCopy(self):
    parts = vtk.vtkActorCollection()
    self.mainAssembly.GetActors(parts)
    parts.InitTraversal()
    numParts = parts.GetNumberOfItems()
    copiedAssembly = vtk.vtkAssembly()
    for i in xrange(numParts):
        subActor = parts.GetNextActor()
        copiedActor = vtk.vtkActor()
        copiedActor.ShallowCopy( subActor );
        copiedAssembly.AddPart(copiedActor)
    return copiedAssembly

Thanks in advance of any help.

Wesley Brooks



More information about the vtkusers mailing list