Skip to content

Instantly share code, notes, and snippets.

@amelkor
Last active February 13, 2023 16:31
Show Gist options
  • Select an option

  • Save amelkor/39e2942838f379b0d0569b2ea65c3690 to your computer and use it in GitHub Desktop.

Select an option

Save amelkor/39e2942838f379b0d0569b2ea65c3690 to your computer and use it in GitHub Desktop.
Blender loop actions which contain specified words by duplicating the first frame
import bpy
actions_to_check = ["Walk", "Wait", "Run"]
def duplicate_frames(action):
start_frame = action.frame_range[0]
end_frame = action.frame_range[1]
new_frame = end_frame + 1
for fcurve in action.fcurves:
fcurve.keyframe_points.insert(frame=new_frame, value=fcurve.evaluate(start_frame))
for action in bpy.data.actions:
action_name = action.name.lower()
if any(keyword.lower() in action.name for keyword in actions_to_check):
duplicate_frames(action)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment