I'm developing an addon that need to capture the position of the same object in one and other frame. Actually I had to create four buttons for it, one to put on start frame, other to end frame, other to capture start frame positions and other to capture end frame positions. I tryied to do it in one command:

import bpy

frame1 = bpy.data.scenes["Scene"].frame_start
bpy.context.scene.frame_current = frame1


frame2 = bpy.data.scenes["Scene"].frame_end
bpy.context.scene.frame_current = frame2


I tryied to put the commands update() and redraw() but it doesnt works, I read in some places that the problem is in the way of Blender works with the bpy.ops.* commands.

Thanks for the attention.


You should be using frame_set

import bpy

def obj_pos(obj, frame):
    print("frame:", frame)
    print("object location:", obj.location)

me = bpy.context.active_object
frame1 = bpy.data.scenes["Scene"].frame_start

obj_pos(me, frame1)

frame2 = bpy.data.scenes["Scene"].frame_end

obj_pos(me, frame2)
  • $\begingroup$ obj.matrix_world.translation will give global location, taking into account hierarchy, constraints, physics etc. $\endgroup$
    – batFINGER
    Dec 30 '18 at 17:59
  • $\begingroup$ Wow! It works perfectly! I change a little the code and run! ciceromoraes.com.br/screenshots/GENERATE.png Thank you very much! $\endgroup$
    – cogitas3d
    Dec 30 '18 at 18:30
  • $\begingroup$ Wow! It works perfectly! I change a little the code and run! $\endgroup$
    – cogitas3d
    Apr 14 '20 at 14:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.