[Paraview] Combining vtk and paraview python scripts

Andy Bauer andy.bauer at kitware.com
Tue Jul 14 15:53:30 EDT 2015


All of that functionality is available through pvpython, or pvbatch in
parallel. I'd suggest you look into using the GUI's Python trace
functionality to help you make that script. pvpython can also be used as an
interactive Python shell if you want.

On Tue, Jul 14, 2015 at 3:43 PM, Jeff Becker <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 http://www.paraview.org/Wiki/Python_Programmable_Filter.
>
>
> 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.
>
> -jeff
>
>
> On Tue, Jul 14, 2015 at 2:59 PM, Jeff Becker <jeffrey.c.becker at nasa.gov>
> wrote:
>
>> Hi.
>>
>> 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.SetDataScalarTypeToFloat()
>> vtkImporter.SetNumberOfScalarComponents(1)
>> 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')
>>
>> writer=vtk.vtkXMLImageDataWriter()
>> writer.SetFileName(out_fname)
>> writer.SetInputConnection(vtkImporter.GetOutputPort())
>> writer.Write()
>>
>> and the ParaView script starts like this:
>>
>> from paraview.simple import *
>>
>> paraview.simple._DisableFirstRenderCameraReset()
>>
>> 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
>> animationScene1.UpdateAnimationUsingDataTimeSteps()
>>
>> # 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.
>>
>> Thanks.
>>
>> -jeff
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the ParaView Wiki at:
>> http://paraview.org/Wiki/ParaView
>>
>> Search the list archives at: http://markmail.org/search/?q=ParaView
>>
>> Follow this link to subscribe/unsubscribe:
>> http://public.kitware.com/mailman/listinfo/paraview
>>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/paraview/attachments/20150714/589ca7c6/attachment.html>


More information about the ParaView mailing list