[vtkusers] [Paraview] Combining vtk and paraview python scripts
jeffrey.c.becker at nasa.gov
Mon Jul 20 14:08:24 EDT 2015
On 07/18/2015 05:17 PM, Berk Geveci wrote:
> To elaborate on what Andy said, you can stick your entire VTK script
> in side the programmable source. Which you can use in batch mode as
> well. If you want to keep your VTK script as a reusable code, I
> recommend making it a module that you import from the programmable source.
So if the last thing my VTK script does is set up a vtkImageImport
object should that work as a programmable source (I tried but ParaView
didn't get any bounds or scalar field name even though I set them up)?
If not, what else do I need to do? Thanks.
> On Tue, Jul 14, 2015 at 3:43 PM, Jeff Becker
> <jeffrey.c.becker at nasa.gov <mailto:jeffrey.c.becker at nasa.gov>> wrote:
> On 07/14/2015 12:20 PM, Andy Bauer wrote:
>> ParaView's Python Programmable Filter and Python Programmable
>> Source use VTK Python wrapping to do the work while making it
>> available in Paraview. Check out
> Thanks. That's pretty neat, but what I'd really like is a
> standalone script I can run in batch mode (no interaction) to
> generate one png file per timestep for all the timesteps in the
> data set. Essentially I'd like a way to construct a pipeline
> between the vtk.vtkImageImport() object and the ParaView renderView1.
>> On Tue, Jul 14, 2015 at 2:59 PM, Jeff Becker
>> <jeffrey.c.becker at nasa.gov <mailto:jeffrey.c.becker at nasa.gov>> wrote:
>> As a proof of concept, I have a vtk script that reads some
>> binary data, and produces a vti file. I then have a second
>> script that I generated using ParaView's tracing facility
>> while viewing the data. Now I'd like to combine them, so as
>> to eliminate the intermediate file, i.e., go from binary data
>> directly to rendering. To be specific, my vtk script ends
>> like this:
>> steinbmag = steinbmag.reshape(nx,ny,nz).T
>> vtkImporter = vtk.vtkImageImport()
>> vtkImporter.CopyImportVoidPointer(steinbmag, steinbmag.nbytes)
>> vtkImporter.SetDataExtent(0, nx-1, 0, ny-1, 0, nz-1)
>> vtkImporter.SetWholeExtent(0, nx-1, 0, ny-1, 0, nz-1)
>> vtkImporter.SetScalarArrayName('B field magnitude')
>> and the ParaView script starts like this:
>> from paraview.simple import *
>> filepfx = '/nobackup/jcbecker/steinBmag_0'
>> infile = filepfx+'.vti'
>> # create a new 'XML Image Data Reader'
>> steinBmag_ = XMLImageDataReader(FileName=infile)
>> steinBmag_.CellArrayStatus = 
>> steinBmag_.PointArrayStatus = ['B field magnitude']
>> # get animation scene
>> animationScene1 = GetAnimationScene()
>> # update animation scene based on data timesteps
>> # get active view
>> renderView1 = GetActiveViewOrCreate('RenderView')
>> # uncomment following to set a specific view size
>> renderView1.ViewSize = [1090, 761]
>> I'm looking at the VTK examples and pvpython documentation,
>> but any help is appreciated.
>> Powered by www.kitware.com <http://www.kitware.com>
>> Visit other Kitware open-source projects at
>> Please keep messages on-topic and check the ParaView Wiki at:
>> Search the list archives at:
>> Follow this link to subscribe/unsubscribe:
> Powered by www.kitware.com <http://www.kitware.com>
> Visit other Kitware open-source projects at
> Please keep messages on-topic and check the ParaView Wiki at:
> Search the list archives at: http://markmail.org/search/?q=ParaView
> Follow this link to subscribe/unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the vtkusers