Thank you, Utkarsh but it is not exactly what I am looking for because the variables of the code are reset every timestep.
The goal is to show the date of the simulation in the screen, using a start date and updating it every timestep, since the animation track run every timestep I’ve removed the part with TimeKeeper.Time
Python animation try code:
day = 28
month = 1
year = 2020
hour = 0
minute = 0
unitOfTime = 15
def start_cue(self):
global day
global month
global year
global hour
global minute
global unitOfTime
minute += unitOfTime
if(minute == 60 ):
hour+=1
minute = 0
if(hour == 24):
day+=1
hour = 0
if(day == 32):
month+=1
day = 1
if(month == 13):
year+=1
month = 1
return str(day) + '/' + str(month) + '/' + str(year) + ' ' + str(hour) + ':' + str(minute)
def tick(self): pass
def end_cue(self): pass
Code before the changes:
from paraview.simple import *
from paraview.vtk import vtkCommand
rv = GetActiveView()
tk = GetTimeKeeper()
dia = 28
mes = 1
ano = 2020
hora = 0
minuto = 0
unidade = 15
timeStep = tk.Time
nextTimeStep = timeStep+1
def dataDia():
global dia
global mes
global ano
global hora
global minuto
global unidade
global timestep
global nextTimeStep
if(timeStep >= nextTimeStep):
nextTimeStep+=1
minuto += unidade
if(minuto == 60 ):
hora+=1
minuto = 0
if(hora == 24):
dia+=1
hora = 0
if(dia == 32):
mes+=1
dia = 1
if(mes == 13):
ano+=1
mes = 1
return str(dia) + '/' + str(mes) + '/' + str(ano) + ' ' + str(hora) + ':' + str(minuto)
def callback(caller, event):
text1.Text = dataDia()
timeStep = tk.Time
text1 = Text()
text1Display = Show(text1, rv, 'TextSourceRepresentation')
rv.GetInteractor().AddObserver(vtkCommand.AnimationCueTickEvent, callback, 1.0)