ParaView MED with pvpython and pvbatch

Paraview with MED support has been presented previously. This post shows how to run scripts with interactive python console or batch. Thanks to Kirk Morgan for testing and sharing the info !

Monitor the GUI from a Python CMD

Here we show how to monitor ParaView 5.6 with MED with an interactive Python execution. 3 batch files are needed. Each batch loads environment variables and then execute a Paraview program. You may create these file and put at root directory of your Paraview installation.

1. run_pvserver.bat

call "%~dp0\WORK\set_env.bat"
CALL C:\ParaView56\WORK\set_env.bat"
CALL "%PDIR%\env_launch.bat"
pvserver --multi-clients

2. run_paraview.bat

call "%~dp0\WORK\set_env.bat"
CALL "%PDIR%\env_launch.bat"
paraview --server-url=cs://localhost

3. run_pvpython.bat

call "%~dp0\WORK\set_env.bat"
CALL "%PDIR%\env_launch.bat"

pvserver with multi-client, pvpython and paraview batch files

First you may execute run_pvserver.bat, either by double clicking on it or in a CMD prompt. It will open a Paraview server instance.
Then you may execute run_paraview.bat. It will open a GUI and connect to the server:

ParaView GUI openend and connected to server on Windows

Finally execute run_pvsimple.bat. It will open a python console

Paraview pvpython opened and connected to server on Windows

From the python prompt you can import Paraview commands, connect to the server and execute Paraview commands. Let’s for example open a file:

from paraview.simple import *
pv_object = MEDReader(FileName="linear-static.rmed")

You may notice that the GUI has synchronized and the object file may appear in the treeview:

Paraview with MED support GUI synchronized to pvserver

To go further, you may take a look to paraviw python wiki for more info about what is possible to do with pvsimple. Otherwise you can also dump a study from Salome-Meca:

Dump ParaVis script from Salome-Meca on Windows

Save at

Save Salome-Meca paraview python commands on Windows

Edit and get inspiration from what you have done manually in ParaVis:

How to use Salome-Meca paraview python commands

Run a script with pvbatch

As shown in previous paragraph it is also possible to run directly with pvbath. Let’s create a file run_pvbath.bat

call "%~dp0\WORK\set_env.bat"
CALL "%PDIR%\env_launch.bat"
pvbatch %1

You can execute a script by running run_pvbatch.bat %1 where %1 is filename of script in same directory as .bat files.


You can now use Paraview and have some fun with interactive python, make your own tool and start to automate your work !

One thought on “ParaView MED with pvpython and pvbatch

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s