# Auto execution of a Programmable Filter

**URL:** https://discourse.paraview.org/t/auto-execution-of-a-programmable-filter/3306
**Category:** ParaView Support
**Tags:** python
**Created:** [January 10, 2020, 2:54pm UTC](https://discourse.paraview.org/t/auto-execution-of-a-programmable-filter/3306 "2020-01-10T14:54:43Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![wsherman](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/w/8797f3/32.png) [@wsherman](https://discourse.paraview.org/u/wsherman)
#### Post date: [January 10, 2020, 2:54pm UTC](https://discourse.paraview.org/t/auto-execution-of-a-programmable-filter/3306/1 "2020-01-10T14:54:43Z")

</div>

Hello all,

My goal is to have an object (a compass) that I can put at the top of my ParaView animation to  
always show the direction of view.

I’ve tried a couple of ways I thought this might work, but have yet to find a workable solution.

First I tried to put the compass in it’s own RenderView and use a LiveProgrammableSource with a quick-timer rerender to copy the camera orientation (but not location) from one view to the other. And while I can get the orientation copied once, it doesn’t work on a continual basis.  
(For this I used the timing script from: [update automatic data input](https://discourse.paraview.org/t/update-automatic-data-input/3222))

So then I thought a better solution might just be to translate the compass to “follow” the camera,  
and reposition it in front of the camera (and up a little) whenever the camera moves. For this,  
I can’t use a source, so I use the ProgrammableFilter, which doesn’t have the “Live” option.  
So I can gert this to work – once – but I don’t know a way to make it happen all the time. Ideally  
I’d like it to work continually, including when I move the camera with the mouse in the RenderView.  
But I’d be happy if I could figure out a way to trigger the ProgrammableFilter on an ongoing basis.  
Is there a way to use the ResquestUpdateExtent script option?

ASIDE: as I mentioned, my ideal would be to have a script that executes while I’m changing  
the camera view with the mouse, but even the LiveProgrammableSource freezes whenever  
the mouse is engaged.

FYI: here’s the “Script” portion that I’m using for the PrrogrammableFilter to move my compass:

```
# moveToCam.py
from paraview import servermanager
from vtk.vtkCommonTransforms import vtkTransform
from vtk.vtkFiltersGeneral import vtkTransformPolyDataFilter
import operator
import numpy as np

pdi = self.GetPolyDataInput()
pdo = self.GetPolyDataOutput()

# Get information about the main (current) camera
view = servermanager.GetRenderView()
camera = view.GetActiveCamera() 

# Calculate a location that's in front of the camera (with minor adjustments)
camLocation = camera.GetPosition()
dirVector = tuple(map(operator.sub, camera.GetFocalPoint(), camLocation))
normDir = dirVector / np.linalg.norm(dirVector)
newLocation = camLocation + normDir * 100 + [0.0, -15.0, 0.0]

# Create a tranformation object that moves objects to be in front of the camera
# as well as doing a scaling operation.
transform = vtkTransform()
transform.Translate(newLocation)
transform.Scale(10.0, 10.0, 10.0)

# Create the poly data filter that uses the above transform
transformPD = vtkTransformPolyDataFilter()
transformPD.SetTransform(transform)
transformPD.SetInputData(pdi)
transformPD.Update()

# Apply the transform to the output (via the Poly Data Filter)
pdo.ShallowCopy(transformPD.GetOutput())

```

Thanks,  
Bill
