# Macro scripting for animation of concurrent frames

**URL:** https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113
**Category:** ParaView Support
**Created:** [August 14, 2020, 10:07pm UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113 "2020-08-14T22:07:33Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Partth\_Laad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/partth_laad/32/4699_2.png) [@Partth\_Laad](https://discourse.paraview.org/u/Partth_Laad)
#### Post date: [August 14, 2020, 10:07pm UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/1 "2020-08-14T22:07:33Z")

</div>

Hi all,

I had a quick question. Is there a Python scripting command list for macro creation in PV? I tried to find and follow the information from the user guide, but was not sure if that was the entire list of commands. I would think not but I am unfamiliar with Python at the moment. I ask as I have multiple files (named \_1.case, \_2.case, and so on) and wish to create a loop to read these successive data sets into the same save state file and generate an animation from the render frames I have setup. Namely, I know the commands from the Python interface in PV to setup the frames (from user guide), but was not sure if there were specific commands to read consecutive files in a given path by means of a successive loop.

I cannot load all of the files simultaneously as there are 200 files with each being multiple GBs in size.

If anyone has any slight pointers I would appreciate it. This was the approach I did in Tecplot and is something I am sure I can do here as I like PV much better and wish to use it fully. But my concern lies with if there was any specific PV commands to be used for such scripting in PV. Thank you.

---

<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: [August 31, 2020, 9:35am UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/2 "2020-08-31T09:35:30Z")

</div>

I’m not really clear on what you want to do, but If you want to loop on the file in a directory to create a reader to open each file and closing it, a simple loop should work without issues.

Something like :

```auto
import os
import gc

for filename in os.listdir(directory):
    if filename.endswith(".case"): 
         reader=OpenDataFile(filename)
# do stuff
         Delete(reader)
         del reader
         gc.collect()
        continue
    else:
        continue

```

---

<div class="post-metadata">

### Author: ![Partth\_Laad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/partth_laad/32/4699_2.png) [@Partth\_Laad](https://discourse.paraview.org/u/Partth_Laad)
#### Post date: [September 2, 2020, 3:19am UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/3 "2020-09-02T03:19:34Z")

</div>

Hello,

Yes the idea is I want to setup a single .pvsm state file and successively load numbered files in order and calculate say the magnitude of the gradient of some field variable for each file and generate an animation of sorts/ export screenshots of each file. This sample script is very helpful so thank you. My idea is I want to make an animation with the exported screenshots (png). I saw the manual online after making the initial post and saw some sample scripts, but I am still new to the scripting and animation tools.

-Partth

 ![3612606C6501412FB2B080FCEC5A63D0.png](https://discourse.paraview.org/uploads/default/original/2X/9/995bef0139c48731961f831482e1a68b58739442.png)

---

<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: [September 2, 2020, 7:26am UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/4 "2020-09-02T07:26:22Z")

</div>

In this case, you want to use the file series mechanism. Just number your file like `file1.case, file2.case`, and open `file..case` instead.

---

<div class="post-metadata">

### Author: ![Partth\_Laad](https://discourse.paraview.org/user_avatar/discourse.paraview.org/partth_laad/32/4699_2.png) [@Partth\_Laad](https://discourse.paraview.org/u/Partth_Laad)
#### Post date: [September 2, 2020, 11:43am UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/5 "2020-09-02T11:43:25Z")

</div>

Yea I saw this can use the legacy format. Is it ok if the files are also having the syntax: file\_1.case, file\_2.case, etc?

If so I just need to use adjust the script for file export. Thanks.

-Partth

---

<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: [September 2, 2020, 11:47am UTC](https://discourse.paraview.org/t/macro-scripting-for-animation-of-concurrent-frames/5113/6 "2020-09-02T11:47:11Z")

</div>

Yes it is ok.
