# Move Source (disk or sphere) according to time dependent function

**URL:** https://discourse.paraview.org/t/move-source-disk-or-sphere-according-to-time-dependent-function/2251
**Category:** ParaView Support
**Created:** [July 18, 2019, 6:08pm UTC](https://discourse.paraview.org/t/move-source-disk-or-sphere-according-to-time-dependent-function/2251 "2019-07-18T18:08:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![matse](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/m/f0a364/32.png) [@matse](https://discourse.paraview.org/u/matse)
#### Post date: [July 18, 2019, 6:08pm UTC](https://discourse.paraview.org/t/move-source-disk-or-sphere-according-to-time-dependent-function/2251/1 "2019-07-18T18:08:57Z")

</div>

Hello,  
I need to overlay a disk or sphere over my data and move it along a given function, that depends on the simulation time t. So e.g. I want a disk to move along the x-axis during the simulation time - is this possible? At the moment I create the disk by hand, which is nice for one single timestep, automating this would be a great help.

Thanks in advance,

Mathias

//Edit:  
I found a similar question here:  
[https://public.kitware.com/pipermail/paraview/2014-September/032153.html](https://public.kitware.com/pipermail/paraview/2014-September/032153.html) and there a similar problem could be solved with a ProgrammableFilter. So I tried this on my problem too and at the moment I have this programmable filter on my sphere:

from vtk import vtkDataObject  
from paraview.simple import GetActiveView

pdi = self.GetPolyDataInput()  
pdo = self.GetPolyDataOutput()  
newPoints = vtk.vtkPoints()  
numPoints = pdi.GetNumberOfPoints()

view = GetActiveView()  
time = view.ViewTime

for i in range(0, numPoints):  
coord = pdi.GetPoint(i)  
x, y, z = coord[:3]  
x = x + time  
y = y  
z = z  
newPoints.InsertPoint(i, x, y, z)  
pdo.SetPoints(newPoints)

this works, when I trigger it manually each timestep. Is it possible, that the filter is executed automatically on each new timestep?

---

<div class="post-metadata">

### Author: ![cory.quammen](https://discourse.paraview.org/user_avatar/discourse.paraview.org/cory.quammen/32/11193_2.png) [@cory.quammen](https://discourse.paraview.org/u/cory.quammen)
#### Post date: [July 19, 2019, 2:03pm UTC](https://discourse.paraview.org/t/move-source-disk-or-sphere-according-to-time-dependent-function/2251/2 "2019-07-19T14:03:50Z")

</div>

You can do this with some of the animation controls.

Let’s say you add a **Sphere** source. It’s name in the _Pipeline Browser_ will be “Sphere1”. Open up the _Animation View_. In the popup menu to the right of the blue plus sign, select, “Python”, then click the plus sign. In the track to the right of the new animation trick, double-click your mouse. In the “Edit Python Animation Track” dialog that appears, enter this script:

```python
from paraview.simple import *

def start_cue(self): pass

def tick(self):
  tk = GetTimeKeeper()
  t = tk.Time
  center = [t, 0, 0]
  s = FindSource('Sphere1')
  s.Center = center

def end_cue(self): pass

```

This will move the sphere along the _x_-axis according to ParaView’s current time.
