4

I tried this code that I found in the net in order to print the location of the camera in each frame of the animation.

import bpy

camera=bpy.data.objects['Camera']
sce = bpy.context.scene

for f in range(sce.frame_start, sce.frame_end+1):
    sce.frame_set(f)
    print("Frame %i" % f)
    print(camera.location)

After execution I get a fix location while the animation is fine.

I get like this:

<Vector (-35.4940, -2.9554, 5.3437)>
Frame 41
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 42
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 43
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 44
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 45
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 46
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 47
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 48
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 49
<Vector (-35.4940, -2.9554, 5.3437)>
Frame 50
<Vector (-35.4940, -2.9554, 5.3437)>`

How can I rectify the code ?

I have tried also the code given in this discussion :

How can I get the location of an object at each keyframe?

but it doesn't work. I get the following error :

AttributeError: 'NoneType' object has no attribute 'action'

What is the problem?

Thank you

Ray Mairlot
  • 29,192
  • 11
  • 103
  • 125
mariem
  • 41
  • 1

0 Answers0