# Create camera movement for animations in Python

**URL:** https://discourse.paraview.org/t/create-camera-movement-for-animations-in-python/11869
**Category:** ParaView Support
**Tags:** python
**Created:** [April 13, 2023, 2:53pm UTC](https://discourse.paraview.org/t/create-camera-movement-for-animations-in-python/11869 "2023-04-13T14:53:40Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![F42](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/f/8dc957/32.png) [@F42](https://discourse.paraview.org/u/F42)
#### Post date: [April 13, 2023, 2:53pm UTC](https://discourse.paraview.org/t/create-camera-movement-for-animations-in-python/11869/1 "2023-04-13T14:53:40Z")

</div>

Hello,

I use the “interpolate cameras” feature and manually set 6 positions for the camera path in the GUI. However, the camera movements don’t show up in the python state file nor can I trace them. (I know this is to prevent bloated python scripts)

Is there any workaround or working code snipped about interpolating cameras in python? I would love to make changes in the python code and pvbatch animations…

I am using 5.11.0 and couldn’t find a way to resolve this. The camera placements get tracked and look like this:

```auto
# current camera placement for renderView1
renderView1.CameraPosition = [0.0102328, 0.00547051, 0.0435503]
renderView1.CameraFocalPoint = [0.01, -0.00125, 0.003125]
renderView1.CameraViewUp = [-0.01612050092440396, 0.9863480565605282, -0.16388300939760517]
renderView1.CameraParallelScale = 0.0106066
# Adjust camera

# current camera placement for renderView1
renderView1.CameraPosition = [0.03077353164932608, -0.0004529731381457592, 0.0098734333057557]
renderView1.CameraFocalPoint = [0.01208594227197795, -0.0017499687200504962, 0.0001676446387540233]
renderView1.CameraViewUp = [0.0011748186223604893, 0.9904167730136751, -0.13810588522717943]
renderView1.CameraParallelScale = 0.0106066
# Adjust camera
...

```

Thank you very much

---

<div class="post-metadata">

### Author: ![nicolas.vuaille](https://discourse.paraview.org/user_avatar/discourse.paraview.org/nicolas.vuaille/32/5873_2.png) [@nicolas.vuaille](https://discourse.paraview.org/u/nicolas.vuaille)
#### Post date: [April 17, 2023, 8:04am UTC](https://discourse.paraview.org/t/create-camera-movement-for-animations-in-python/11869/2 "2023-04-17T08:04:37Z")

</div>

You should manually create the camera track and then add some _keyframes_:

```python
# get or create track for current view
track = GetCameraTrack()
track.Mode = 'Interpolate Cameras' # should be the default
keyframe = CameraKeyFrame()
# setup keyframe properties, like KeyTime, Position, FocalPoint and so on
keyframe.KeyTime = time
# add it to the track
track.KeyFrames.append(keyframe)

```
