# How to Animate Multiple VTK files ParaView 5.11

**URL:** https://discourse.paraview.org/t/how-to-animate-multiple-vtk-files-paraview-5-11/11385
**Category:** ParaView Support
**Tags:** python
**Created:** [February 13, 2023, 4:37am UTC](https://discourse.paraview.org/t/how-to-animate-multiple-vtk-files-paraview-5-11/11385 "2023-02-13T04:37:08Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![KaiMJ](https://discourse.paraview.org/user_avatar/discourse.paraview.org/kaimj/32/10887_2.png) [@KaiMJ](https://discourse.paraview.org/u/KaiMJ)
#### Post date: [February 13, 2023, 4:37am UTC](https://discourse.paraview.org/t/how-to-animate-multiple-vtk-files-paraview-5-11/11385/1 "2023-02-13T04:37:09Z")

</div>

I have at least 1000 files of 3D numpy array (96 X 144 X 32) of climate variables that I want to visualize through time.

I have converted the numpy files to VTK files.

My question is, how can I animate the 3D map across time?

Methods and Problems I have encountered:

1. Using ParaView application

- Load some vti (vtk) files (it visualizes correctly). Go to animation view and add new keyframe. Start animation (ParaView crashes and closes. The keyframe causes the crash).

1. pvpython Script.

- I couldn’t find an example that does animation with vtk files.

Could someone show me an example script?

This is the script I got using ChatGPT. I load this into the paraview application ‘load sate’, but doesn’t render anything and outputs

"Traceback (most recent call last):  
File “”, line 3, in start\_cue  
NameError: name ‘Text’ is not defined  
Traceback (most recent call last):  
File “”, line 11, in tick  
NameError: name ‘GetAnimationScene’ is not defined  
Traceback (most recent call last):  
File “”, line 11, in tick

```auto
import sys, glob

from paraview.simple import *

# Load the first VTK file

vtkFileNames = sorted(glob.glob("*_0.vti"))

print(len(vtkFileNames))

print(vtkFileNames[0])

data = XMLImageDataReader(FileName=[vtkFileNames[0]])

# Load the remaining VTK files

for i in range(1, len(vtkFileNames)):

vtkFileName = vtkFileNames[i]

data = AppendDatasets(Input=[data, XMLImageDataReader(FileName=[vtkFileName])])

# Define the time values

timeValues = [i for i in range(len(vtkFileNames) - 1)]

data.PointData.GetArray("TimeValue").SetNumberOfTuples(len(timeValues))

data.PointData.GetArray("TimeValue").SetTuple1(0, timeValues[0])

for i in range(1, len(timeValues)):

data.PointData.GetArray("TimeValue").SetTuple1(i, timeValues[i])

# Show the animation

Show(data)

Render()

# Play the animation

animationScene = GetAnimationScene()

animationScene.Play()

```

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [February 13, 2023, 10:16am UTC](https://discourse.paraview.org/t/how-to-animate-multiple-vtk-files-paraview-5-11/11385/2 "2023-02-13T10:16:37Z")

</div>

Please update the script you pasted: `for` loops are not indented so hard to so what is expected.

From what I understand, you have one `.vti` file per timestep. So try

```auto
OpenDataFile(vtkFileNames)
Show()
Render()

```

see the exact example [here](https://docs.paraview.org/en/latest/UsersGuide/dataIngestion.html#id2)
