I'm trying to write a script that duplicates an action. Ultimately I'm going to be generating an entirely new set of F-curves and key-frames but I thought simply removing all F-curves and re-entering them would be an easy first step. Here's my script right now:
old_nod = bpy.data.actions["GST-nod-1"]
nod = bpy.data.actions["GST-nod-1"].copy()
for i in range(len(nod.fcurves)):
nod.fcurves.remove(nod.fcurves[0])
for f in old_nod.fcurves:
dest = nod.fcurves.new(f.data_path)
for keyframe in f.keyframe_points:
x=keyframe.co[0]
y=keyframe.co[1]
new_keyframe = dest.keyframe_points.insert(x,y)
new_keyframe.handle_left = keyframe.handle_left
new_keyframe.handle_left_type = keyframe.handle_left_type
new_keyframe.handle_right = keyframe.handle_right
new_keyframe.handle_right_type = keyframe.handle_right_type
The script runs without errors, but the new action (nod) doesn't do anything. I think the issue has something to do with action groups, but I'm not sure how to assign the correct action groups to the action or the F-curves to the action groups.
Any help is appreciated, thanks.