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

**URL:** https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221
**Category:** ParaView Support
**Created:** [January 13, 2021, 4:58pm UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221 "2021-01-13T16:58:08Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Jimbles](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jimbles/32/474_2.png) [@Jimbles](https://discourse.paraview.org/u/Jimbles)
#### Post date: [January 13, 2021, 4:58pm UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221/1 "2021-01-13T16:58:08Z")

</div>

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 🙂

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 14, 2021, 9:38am UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221/2 "2021-01-14T09:38:41Z")

</div>

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

See here:

> <https://stackoverflow.com/questions/45236721/controlling-paraview-gui-from-python-idle/46407769#46407769>

---

<div class="post-metadata">

### Author: ![Jimbles](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jimbles/32/474_2.png) [@Jimbles](https://discourse.paraview.org/u/Jimbles)
#### Post date: [January 14, 2021, 1:47pm UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221/3 "2021-01-14T13:47:13Z")

</div>

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.

```auto
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!

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [January 14, 2021, 1:55pm UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221/4 "2021-01-14T13:55:08Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Jimbles](https://discourse.paraview.org/user_avatar/discourse.paraview.org/jimbles/32/474_2.png) [@Jimbles](https://discourse.paraview.org/u/Jimbles)
#### Post date: [January 14, 2021, 3:30pm UTC](https://discourse.paraview.org/t/repeatedly-calling-paraview-from-matlab-run-in-existing-gui-window/6221/5 "2021-01-14T15:30:17Z")

</div>

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
