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

@PGMath

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)

@PGMath

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)

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)
Source Link
Ratt
  • 2.2k
  • 1
  • 10
  • 17

@PGMath

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)