Skip to main content
2 of 2
deleted 11 characters in body
PGmath
  • 25.3k
  • 17
  • 106
  • 202

Not sure I'm accurately getting what you asked accomplished here, but see below code.

If you do not mind this generating extra keyframes in your animation you can copy paste into text editor & run script.

#######################################################################
# be sure to save blend file before running script                    #
# understand that this creates new keyframes every fstep of animation #
# it is recommended to test this on a dummy file before use           #
#######################################################################

import bpy

list_of_all_scenes = bpy.data.scenes
fstep=5

if bpy.data.is_saved:
    for y in list_of_all_scenes:
        bpy.context.screen.scene = y
        ########## add custom properties to objects ############
        for obj in bpy.data.objects:
            obj["XVel"]=0.0
            obj["YVel"]=0.0
            obj["ZVel"]=0.0
        ########################################################
        for f in range(y.frame_start, y.frame_end+fstep,fstep):
            y.frame_set(f)
            for obj in bpy.data.objects:                       
                currentx=obj.location.x
                currenty=obj.location.y
                currentz=obj.location.z
                y.frame_set(f-fstep)
                oldx=obj.location.x
                oldy=obj.location.y
                oldz=obj.location.z
                y.frame_set(f+fstep)
                obj['XVel']=(currentx - oldx)/fstep
                obj['YVel']=(currenty - oldy)/fstep
                obj['ZVel']=(currentz - oldz)/fstep
                obj.keyframe_insert(data_path='["XVel"]', frame=bpy.context.scene.frame_current)
                obj.keyframe_insert(data_path='["YVel"]', frame=bpy.context.scene.frame_current)
                obj.keyframe_insert(data_path='["ZVel"]', frame=bpy.context.scene.frame_current)
Ratt
  • 2.2k
  • 1
  • 10
  • 17