Search code examples
paraview

Paraview - get current time_index in ProgrammableSource


I have an array that has exactly as many rows as there are time steps in the animation. Now I want to have the row associated to the current time step as vtkTable as output of a ProgrammableSource. My code (for the ProgrammableSource) so far looks like this:

import numpy as np

file = "table.csv"
tbl = np.genfromtxt(file, names=True, delimiter=",", autostrip=True)
for n in tbl.dtype.names:
    v = tbl[n][2]
    output.RowData.append(v, n)

Which currently always writes out the third line (v = tbl[n][2]). Is there a way to pass the current time step (index) in place of [2]?


Solution

  • The best is to make your Programmable Source timesteps aware.

    So you should fill the Information Script (advanced property) to declare the list of available timesteps, and then in the main script, get current timestep and output the data you want.

    See this example from the doc.