Repeatedly calling ParaView from Matlab - run in existing GUI window?

I am writing a function to call paraview from matlab for better visualisation (in Windows). Currently matlab writes some settings and target VTU/K filenames to a json file and then a python script reads this and displays the results.

I am calling paraview by the command line in matlab e.g. system('paraview --script=myscript.py') , which works fine but as I tweak things in matlab I end up with hundreds of paraview windows open!

I was wondering if it were possible to run a script from the command line in an existing paraview GUI? Or would an “Update” macro be a good work around?

Thanks for any help you can offer :slight_smile:

Yes, but only through some kind of a trick, using ParaView server multi-client mode.

See here:

1 Like

Thanks very much! This approach seems to work well, im sure it is possible to start the pvserver instance through matlab so most of this can be handled by the script. I was getting errors because I didnt add Disconnect("localhost") at the end of the scripts or before closing the pvpython terminal.

Apologies for the basic question but running the following code from the pvpython terminal shows the cone, whereas if I run it through pvpython myscript.py the cone is not displayed - it is hidden in the pipeline browser.

from paraview.simple import *
Connect("localhost")
Cone()
Show()
Disconnect("localhost")

If I add RenderAllViews() it shows up in paraview but also along with a separate window briefly. Could you please point me in the right direction to avoid this?
Thanks!

Your script work perfectly here (ParaView 5.9-RC3, ArchLinux).
Are you sure that Show is present in your script ?

The Render behavior you see is expected.

Thanks for checking that. The script is definitely as I showed. Im using ParaView 5.8.1-Windows-Python3.7-msvc2015-64bit on Windows 10. I can try a different version and see if that changes things