Search code examples
paraviewpvpython

Unable to render something with pvpython (paraview)


I'm new on paraview, and I want to make a script that render a vtk file, using only pvpython. Therefore, I wrote this script

from paraview.simple import *
from paraview.vtk.vtkFiltersSources import vtkSphereSource
paraview.simple._DisableFirstRenderCameraReset()
renderView1 = GetActiveViewOrCreate('RenderView')
renderView1.ViewSize = [1080, 860]
reader = OpenDataFile([nameFile...])
Interact()
Render()

But when I launch the script with pvpython using the command .\pvpython.exe .\myscript.py, the visualisation shows an empty window, without my mesh Visualisation without my mest

Does someone have an idea, of why my mesh isn't rendered in the view ?


Solution

  • In order to add your reader output in the view, you have to call Show() before Interact().

    Show() will add the current active object in the view. To explicitly add your reader output in the view, you may use Show(reader)

    Calling Render() is also unneeded just after Interact()

    edit Here is a minimal script to load a file and display it centered in a default 3d view:

    from paraview.simple import *
    reader = OpenDataFile("/path/to/your/file")
    Show()
    Interact()