0
$\begingroup$

enter image description here

I would like to know if there is an addon or its already in-built function in blender. I need to paste keyframes realative to the existing pose, so for example I need a character starting with a different pose now. What should happen is, I paste this new pose before the animation keys, copy/cut all of the animation keyframes and paste them again over or near that pose keyframe, and it should offset all the keyframe values relative to that previous pose. In maya it is called "paste connect" if i am not mistaken.

https://youtube.com/clip/UgkxkzD9WZT67_vZMjXUpEp0CynleFy621gf?si=2KH2zpfrU5Dxjj0F

$\endgroup$

1 Answer 1

0
$\begingroup$

enter image description here

this is what i have by far:

import bpy

# Get the active object
obj = bpy.context.active_object

# Get the selected channels
selected_channels = [f for f in obj.animation_data.action.fcurves if f.select]

# Loop through each selected keyframe
for channel in selected_channels:
    
    # Get the previous keyframe of the current track's channel
    first_keyframe = channel.keyframe_points[0].co[1]
    second_keyframe = channel.keyframe_points[1].co[1]
    
    # Calculate the offset value
    offset = first_keyframe - second_keyframe
    
    # Shift the selected keyframes of that channel by the calculated offset
    for keyframe in channel.keyframe_points[1:]:
        keyframe.co[1] += offset
        keyframe.handle_left[1] += offset
        keyframe.handle_right[1] += offset
        channel.update()
$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .