I'm new to scripting inside blender (two days). I have a camera folowing a path (a circle).
I have written the following code to get the location and rotation for each frame and write it to a file:
import bpy
transformMetrix=open('C:\\Users\\sunimalm\\Desktop\\transformMetrix.txt','w')
for f in range(bpy.context.scene.frame_start,bpy.context.scene.frame_end):
for obj in bpy.context.selected_objects:
transformMetrix.write('\n'+obj.name+'\n')
transformMetrix.write('\n'+ str(f)+'\n')
transformMetrix.write('Location : ' + str(obj.location.x) +' '+ str(obj.location.y) +' '+ str(obj.location.z) +'\n')
transformMetrix.write('rotation : ' + str(obj.rotation_euler.x) +' '+str(obj.rotation_euler.y) +' '+str(obj.rotation_euler.z)+'\n')
transformMetrix.write('scale : ' + str(int(obj.scale.x)) +' '+str(int(obj.scale.y))+' '+str(int(obj.scale.z)) +'\n')
transformMetrix.close()
When I play and run the script I only get the same rotation and location matrix for every frame.
What am I doing wrong here?
Then I tried to put above code inside a function and append it to a handler, but I still get the same output:
bpy.app.handlers.frame_change_post.append(function)
fcurve.evaluate()
to get the values at a given frame. $\endgroup$