def frame_from_strip(context, anim_or_strip, frame=None, absolute=False): "Convert the keyframe.co inside scaled nla strip to timeline frame" if frame is None: frame = context.scene.frame_current_final anim = anim_or_strip.id_data.animation_data strip = anim_or_strip tweak = anim.use_tweak_mode is_strip = Is.nla_strip(strip) if (tweak or is_strip): if (tweak and is_strip and strip.active) and hasattr( anim, 'nla_tweak_strip_time_to_scene'): value = anim.nla_tweak_strip_time_to_scene(frame, invert=False) else: if not is_strip: strip = Get.active_strip(anim) value = Get.strip_co_frame(strip, co=frame) else: value = frame if absolute: return value else: return (round(value, 6))
def frame_to_strip(context, anim_or_strip, frame=None, absolute=False): "Convert the keyframe.co/frame to correct frame inside nla strip" if frame is None: frame = context.scene.frame_current_final anim = anim_or_strip.id_data.animation_data strip = anim_or_strip tweak = anim.use_tweak_mode is_strip = Is.nla_strip(strip) if (tweak or is_strip): if is_strip and strip.active and hasattr( anim, 'nla_tweak_strip_time_to_scene'): value = anim.nla_tweak_strip_time_to_scene(frame, invert=True) else: if not is_strip: strip = Get.active_strip(anim) value = Get.strip_co_frame(strip, frame=frame) else: # Null call, so just return scene frame value = frame if absolute: return value else: return (round(value, 6))
def nla_blend_name(anim_or_strip): if Is.nla_strip(anim_or_strip): blend_type = anim_or_strip.blend_type else: blend_type = anim_or_strip.action_blend_type if blend_type == 'REPLACE': return 'Base' else: return blend_type.replace('COMBINE', 'Layer').title()