Forum Archive › Keyframes fast selection › Reply To: Keyframes fast selection
***Edit*** Forgot to mention I added to the select menu on the dopesheet editor.
Well, that was surprisingly easy. I just added an append to the register and a remove in the unregister.
bpy.types.DOPESHEET_MT_select.append(menu_func)
bpy.types.DOPESHEET_MT_select.remove(menu_func)
So the whole script is:
bl_info = {
"name": "Partial Deselect",
"blender": (3, 0, 0),
"category": "Object",
}
import bpy
def main(context, nthkey=2):
for action in bpy.data.actions:
for channel in action.fcurves:
for key in channel.keyframe_points.values()[0::nthkey]:
key.select_control_point = False
key.select_left_handle = False
key.select_right_handle = False
class ChannelSelect4Key(bpy.types.Operator):
"""Partial deSelect""" # Use this as a tooltip for menu items and buttons.
bl_idname = "anim.channel_select_4th"
bl_label = "DeSelect 1 keyframe every 4 keys"
bl_options = {'REGISTER', 'UNDO'} # Enable undo for the operator.
def execute(self, context):
main(context, 4)
return {'FINISHED'}
class ChannelSelect3Key(bpy.types.Operator):
"""Partial deSelect""" # Use this as a tooltip for menu items and buttons.
bl_idname = "anim.channel_select_3th"
bl_label = "DeSelect 1 keyframe every 3 keys"
bl_options = {'REGISTER', 'UNDO'} # Enable undo for the operator.
def execute(self, context):
main(context, 3)
return {'FINISHED'}
class ChannelSelect2Key(bpy.types.Operator):
'''Select odd keys for selected channels in the dopesheet'''
bl_idname = "anim.channel_select_2nd"
bl_label = "DeSelect 1 keyframe every 2 keys (even)"
bl_options = {'REGISTER', 'UNDO'} # Enable undo for the operator.
def execute(self, context):
main(context, 2)
return {'FINISHED'}
def menu_func(self, context):
self.layout.operator(ChannelSelect4Key.bl_idname)
self.layout.operator(ChannelSelect3Key.bl_idname)
self.layout.operator(ChannelSelect2Key.bl_idname)
def register():
bpy.utils.register_class(ChannelSelect4Key)
bpy.utils.register_class(ChannelSelect3Key)
bpy.utils.register_class(ChannelSelect2Key)
bpy.types.DOPESHEET_MT_select.append(menu_func)
def unregister():
bpy.utils.unregister_class(ChannelSelect4Key)
bpy.utils.unregister_class(ChannelSelect3Key)
bpy.utils.unregister_class(ChannelSelect2Key)
bpy.types.DOPESHEET_MT_select.remove(menu_func)
if __name__ == "__main__":
register()
Or you can download and install as an addon.