Jump to content

[PYTHON]Set Keyframe Slope Type?


Atom

Recommended Posts

Hi All,

I have a script that is setting function types on some keyframes.

I want the keyframe slope to ease in, level off then ease out. After Effects EasyEase style.

It seems that no matter what combination of function types I pass in to my keyframe generator I just can't get the curve shape I want.Untitled-1.jpg

Does anyone know how to alter this code to get the channel shape shown in the image?

node = hou.pwd()

def assignKeyframe (passedParm, passedFrame, passedValue, passedFunctionType='bezier()'):
    if passedParm != None:
        setKey = hou.Keyframe()
        setKey.setFrame(passedFrame)
        setKey.setValue(passedValue)
        passedParm.setKeyframe(setKey)
        passedParm.setExpression(passedFunctionType, hou.exprLanguage.Hscript)
        
def keyframeValue ():
    current_control = node.parm('ctl_value')
    current_control.deleteAllKeyframes()
    minimum_sustain = 4
    
    frames = [1,285,296,356,366,428,438,499,509,572,582,643,654,716,727,786]
    for i in range(len(frames)-1):
        frame_start = frames[i]
        frame_end = frames[i+1]-1
        sustain = frame_end-frame_start
        assignKeyframe(current_control, frame_start-int(minimum_sustain/2), 0.0, 'easeout()')
        assignKeyframe(current_control, frame_start, 1.0, 'bezier()')
        assignKeyframe(current_control, frame_end, 1.0, 'bezier()')
        assignKeyframe(current_control, frame_end+int(minimum_sustain/2), 0.0, 'easein()')

 

ap_keyframe_ease_IN_OUT_issue.hiplc

Edited by Atom
Link to comment
Share on other sites

I think you're not setting the slope and accel values for use with the 'bezier()' expressions. Easiest to figure this out is to start a fresh channel on a new node, key it the way you want to look and then run

print node.asCode(save_channels_only=True)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...