# Animation Camera Orbit Python

**URL:** https://discourse.paraview.org/t/animation-camera-orbit-python/2907
**Category:** ParaView Support
**Tags:** python
**Created:** [November 5, 2019, 1:03pm UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907 "2019-11-05T13:03:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [November 5, 2019, 1:03pm UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/1 "2019-11-05T13:03:39Z")

</div>

Hello, How can reproduce the Animation by Camera Orbit of the graphic client in Python?  
Thanks

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 7, 2019, 9:56am UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/2 "2019-11-07T09:56:18Z")

</div>

Just use the Python trace in ParaView to generate a trace to use in pvpython.

---

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [November 8, 2019, 9:13am UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/3 "2019-11-08T09:13:48Z")

</div>

Hi Mathieu, thanks. The problem is that the trace generate the positions of the camera for an specific case I want a general orbit procedure given camera and positions and rotation center. At the end I am doing this:

```
def saveAnimationOrbit(render_view, path, resolution, animation):
    num_of_keyframes = animation.frames
    animationScene = simple.GetAnimationScene()
    animationScene.ViewModules = [render_view]
    animationScene.NumberOfFrames = num_of_keyframes

    cameraAnimationCue = simple.GetCameraTrack(view=render_view)

    camera = render_view.GetActiveCamera()

    cue = []
    for i in range(0, num_of_keyframes):
        camera.Azimuth(360.0 / num_of_keyframes)
        keyFrame = simple.CameraKeyFrame()
        keyFrame.KeyTime = i * 1.0 / num_of_keyframes
        keyFrame.Position = camera.GetPosition()
        keyFrame.FocalPoint = camera.GetFocalPoint()
        keyFrame.ViewUp = camera.GetViewUp()
        keyFrame.ViewAngle = camera.GetViewAngle()
        cue.append(keyFrame)

    cameraAnimationCue.KeyFrames = cue
    simple.SaveAnimation(path, render_view, ImageResolution=resolution, FrameWindow=[0, num_of_keyframes - 1],
                         FrameRate=animation.frame_rate)

```

What do you think?  
Thanks  
Reynaldo

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 8, 2019, 9:16am UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/4 "2019-11-08T09:16:22Z")

</div>

Seems good enough ! Thanks for sharing your script.

---

<div class="post-metadata">

### Author: ![gilcu2](https://discourse.paraview.org/user_avatar/discourse.paraview.org/gilcu2/32/2183_2.png) [@gilcu2](https://discourse.paraview.org/u/gilcu2)
#### Post date: [November 8, 2019, 9:31am UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/5 "2019-11-08T09:31:07Z")

</div>

Is there a way in the previous script to interpolate frames in order to not render all?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [November 8, 2019, 9:34am UTC](https://discourse.paraview.org/t/animation-camera-orbit-python/2907/6 "2019-11-08T09:34:56Z")

</div>

I do not think so.
