Jump to content

Baking animation to curve from expression


Recommended Posts

I have an imported character animation from abc. I would like to offset the animation to do FX. I have a centroid as that's all i need. I would like to bake that out as an animated curve so I can manually scale the inverse curve to my liking.
I tried using a point() expression to get the transform channels into a transform node. I then tried baking the channels view the baking menu, but it crashed houdini. I'm guessing there's a proper way of doing this........
I heard people were using chops, but also that it was meant for exporting to unity or something? I don't need to export the animation curves to another software. I literally just need animation curves to edit in the animation curve editor.
Thanks!

Link to comment
Share on other sites

here is a simple example with Python, I attached an example:

parm = hou.parm('/obj/geo1/sphere1/ty')

# store all values in list
values=[]
for i in range(100):
  val = parm.evalAsFloatAtFrame(i)
  values.append(val)

# remove parm expression
parm.deleteAllKeyFrames()

# set values from list to keyframes
for i in range(100):
  myKey = hou.Keyframe()
  myKey.setFrame(i)
  myKey.setValue(values[i])
  parm.setKeyframe(myKey)


 

bake_keyframes.hipnc

  • Like 2
Link to comment
Share on other sites

Awesome thanks Julien!

Just wanted to throw this out there in case anyone else needs this script:
1)  the 'F' in parm.deleteAllKeyframes() is lower case.
2)  if the shot does not start at frame 1, but instead 1001, an offset value will need to be calculated for  myKey.setValue(values[j]) where j is i-1001 (for example)
It took me a bit longer than it should've to realize values was trying to pull a value from an index that didn't exist (1001)

Link to comment
Share on other sites

Thanks Wilson, I noticed the lowercase F afterwards and couldn't edit the code unfortunately.
here is a improved code with start/end frame/increment - yes, you can use decimal frames too!
 

import numpy as np

parm = hou.parm('/obj/geo1/sphere1/ty')

startframe = 1001
endframe = 1100
increment = 1

# store all values in list
values=[]

for i in np.arange(startframe, endframe, increment):
  frame = round(i*100)/100.0
  value = parm.evalAsFloatAtFrame(frame)
  mydict = {'frame':frame , 'value':value}
  values.append(mydict)

# remove parm expression
parm.deleteAllKeyframes()

# set values from list to keyframes
for i in values:
  myKey = hou.Keyframe()
  myKey.setFrame(i['frame'])
  myKey.setValue(i['value'])
  parm.setKeyframe(myKey)

 

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...