def active_scs_animation_update(self, context): """Update function for Active SCS Animation record on Objects. :param context: Blender Context :type context: bpy.types.Context :rtype: None """ active_object = context.active_object scs_root_object = _object_utils.get_scs_root(active_object) scene = context.scene # GET ARMATURE OBJECT armature = None if active_object.type == 'ARMATURE': armature = active_object else: children = _object_utils.get_children(scs_root_object) for child in children: if child.type == 'ARMATURE': armature = child break scs_object_anim_inventory = scs_root_object.scs_object_animation_inventory active_scs_anim_i = self.active_scs_animation if len(scs_object_anim_inventory) > active_scs_anim_i: active_scs_anim = scs_object_anim_inventory[active_scs_anim_i] start_frame = active_scs_anim.anim_start end_frame = active_scs_anim.anim_end length = active_scs_anim.length # set frame range properly _animation_utils.set_frame_range(scene, start_frame, end_frame) # set action to armature end properly set preview fps action = None if active_scs_anim.action in bpy.data.actions: action = bpy.data.actions[active_scs_anim.action] _animation_utils.set_fps_for_preview(scene, length, start_frame, end_frame) # ensure animation data block to be able to set action if armature.animation_data is None: armature.animation_data_create() armature.animation_data.action = action # set/reset action of current animation else: print('Wrong Animation index %i/%i!' % (active_scs_anim_i, len(scs_object_anim_inventory))) return None
def anim_range_update(self, context): """If start or end frame are changed frame range in scene should be adopted to new values together with FPS reset. """ active_object = context.active_object if active_object and active_object.type == "ARMATURE" and active_object.animation_data: action = active_object.animation_data.action if action: _animation_utils.set_frame_range(context.scene, self.anim_start, self.anim_end) _animation_utils.set_fps_for_preview( context.scene, self.length, self.anim_start, self.anim_end, )