__author__ = 'thoth'
import bpy
def extend_strip_to_match(strip):
fr0 = None
for fcurve in strip.action.fcurves:
if len(fcurve.keyframe_points)<1:
continue
fr1 = fcurve.keyframe_points[0].co[0]
if fr0 is None or fr1 <fr0:
fr0 = fr1
if fr0 is None:
return
if strip.action_frame_start > fr0:
delta = strip.action_frame_start - fr0
fs1 = strip.frame_start
fe1 = strip.frame_end
strip.action_frame_start = fr0
strip.frame_start = fs1-delta
strip.frame_end = fe1
def extend_nla_strips(action):
for obj in bpy.data.shape_keys:
if obj.animation_data is None:
continue
for track in obj.animation_data.nla_tracks:
for strip in track.strips:
if strip.action==action:
extend_strip_to_match(strip)
#
#
extend_nla_strips(bpy.data.actions['KeyAction'])
|
Blender python API quick-start
Syntax highlighting by Pygments.