No keyframe on timeline when creating keys with Python

   636   2   0
User Avatar
Member
85 posts
Joined: April 2017
Offline
I am trying to set some keys on a LOP Camera with Python.
The motion is there but there is no keys on the timeline!

import hou
myCam = hou.node("/stage").createNode("camera",("test"))

for iter in range(1, 90):
        myVal = hou.Keyframe()
        rotatex = myCam.parm("ry")
        myVal.setFrame(iter)
        myVal.setValue(iter)
        rotatex.setKeyframe(myVal)

Am I missing something?
User Avatar
Member
2539 posts
Joined: June 2008
Offline
That does seem like a redraw bug. If you move your mouse over the Camera transform properties and press the V-KEY, the timeline updates with the keyframes.
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
85 posts
Joined: April 2017
Offline
It turned out it's not a bug, I fixed it with the help of the great SideFX team, Thank you.
Here is the solution if anyone looking for similar case in the future:

SideFX message:

From our developers
For the keyframes to be visible on the timeline, parms need to be added to the channel list.
Creating a keyframe from the UI usually sets the autoscope flag on the parameter, based on a user animation preference. This isn't done automatically from hou.Parm.setKeyframe.

Call:

hou.Parm.setAutoScope(True)
hou.Parm.setAutoSelect(True)
hou.Parm.setScope(True)
hou.Parm.setSelect(True)

before adding the keyframe.
  • Quick Links