Setting keys on parmTuple...

   1911   10   0
User Avatar
Member
41 posts
Joined: May 2021
Offline
As the title says how do you set keys on parmTuple? Let's say I want to key rx ry rz at once, I'm getting an attribute error that a parmTuple object has no setKeyframe(key) attribute?
Edited by kriegmesser74 - Aug. 4, 2021 16:58:21
User Avatar
Member
8683 posts
Joined: July 2007
Offline
should work as long as you are using at least H18.0 and your "key" variable is actually a tuple of hou.Keyframe objects
pt = hou.parmTuple('/obj/geo1/r')
key = hou.Keyframe()
key.setFrame(10)
key.setValue(5)
keys = (key, key, key)
pt.setKeyframe(keys)
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
41 posts
Joined: May 2021
Offline
Again THANKS A LOT!! Well I'm on H17.0 so as it seems to me one can "inject" values as a tuple but has to key them one by one with hou.parm? Is key.setValue mandatory? I'm trying to key whatever values are already present at a frame on timeline...
User Avatar
Member
8683 posts
Joined: July 2007
Offline
I'm not sure if there is such function already, but should be pretty straightforward
following is just a quick mockup, should work for parms and parm tuples

def setKey(parm):
    if type(parm) == hou.ParmTuple:
        parm_tuple = parm
    elif type(parm) == hou.Parm:
        parm_tuple = (parm,)
    else:
        return 0
    
    for parm in parm_tuple:
        key = hou.Keyframe()
        key.setFrame(hou.frame())
        key.setValue(parm.eval())
        parm.setKeyframe(key)
    return 1

    
parm = hou.parmTuple('/obj/geo1/r')    
setKey(parm)
Edited by tamte - Aug. 5, 2021 10:51:16
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
41 posts
Joined: May 2021
Offline
Well again thanks a LOT... in my case code looks like this:

...#Other parameters and objects bla bla bla
...#Let's focus on this one only

Object = hou.node('/obj/L_UpArm_FK_CTRL/')
Object_parameter = Object.parm('/obj/L_UpArm_FK_CTRL/rx').eval()

...#Time to key some stuff

Current_Time=hou.intFrame()
myKey= hou.Keyframe(Current_Time)
Frame_Backwards=Current_Time-1
hou.setFrame(Frame_Backwards)

Object_parameter.setKeyframe(myKey)

Aaaand I get "AttributeError: 'float' object has no attribute 'setKeyframe'"

S**T ... This same approach works for BlendParents node's sliders... keys are created at a proper frame on timeline but on rotations looks like a bug to me... please tell me that I'm wrong...
User Avatar
Member
8683 posts
Joined: July 2007
Offline
cause your ObjectParameter variable is not the parameter but its value

so change this:
Object_parameter = Object.parm('/obj/L_UpArm_FK_CTRL/rx').eval()
to this
Object_parameter = Object.parm('/obj/L_UpArm_FK_CTRL/rx')
Edited by tamte - Aug. 5, 2021 12:11:19
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
41 posts
Joined: May 2021
Offline
Yes, i tried that. it works, but it copies/pastes current keyframe number on the timeline AS a new value for rotation... for example my time slider was on frame number 19 and my "new out of nowhere" rotation was 19... what a madness... do I need to set value with object_parameter as value? How would that look? myKey.setValue(object_parameter) maybe?


EDIT no. 1
YES! myKey.setValue(object_parameter) does the job!

Now the next thing arises... since I'm typing lazy (aren't we all) can I use parmTuple as a variable for setting value of a keyframe? Or to stick with "one by one" style?

Man I wish you are closer... I would buy you a six pack, or a Jack or something...
Edited by kriegmesser74 - Aug. 5, 2021 13:31:09
User Avatar
Member
8683 posts
Joined: July 2007
Offline
No hou.Keyframe can have just a single value
And as mentioned to use setKeyframe on ParmTuple using tuple of values is possible only since 18.0

But you can easily make function that works on tuples as shown here

https://www.sidefx.com/forum/topic/80258/?page=1#post-344889 [www.sidefx.com]

Which currently would key current values at current frame, but can easily be extended to specify value or even frame if needed
Edited by tamte - Aug. 5, 2021 13:50:30
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
41 posts
Joined: May 2021
Offline
Cheers man... thanks a lot... writing functions for setting keys is still beyond my skills in Python... I'm an old MEL Maya guy... this whole hou.blabla thing is sooo... cumbersome... IMHO... I didn't know that one cannot keyframe a value and that parameter won't be updated accordingly... here as it seems one keyframes parameter and updates values... well... sigh...
User Avatar
Member
8683 posts
Joined: July 2007
Offline
one you get hang of it its not that difficult
just paste that function definition into your file and then whenever you need to set a key on parm or parm tuple do:

setKey(myParm)
or
setKey(myParmTuple)

as last 2 lines show, it will set a key at current frame and current values
Edited by tamte - Aug. 5, 2021 15:25:47
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
41 posts
Joined: May 2021
Offline
Well the main reason for all of this mumbo-jumbo with Houdini Python etc. is Houdini's Muscle system, I have a great model of a character (an Orc) in proper T pose (still in retopology phase, but not far from finish)... I could finish it in Maya (full body IKFK switch/match, muscles, facial rig etc.) but Maya's muscles are a bit... obsolete... If I'm particularly lazy I could kick it in Motionbuilder and just add a layer of muscles... but in my twisted mind that feels like cheating. So since you have (obviously) much more mileage in Houdini than me I would appreciate your opinion on torso muscles setup. Is anatomical skeleton (i.e. ribs, clavicles, shoulder blades models) "a must have" before setting up torso muscles, or a bunch of strategically placed and parented nulls can do the trick, or some approximation of a rib cage made of Houdini's bones will suffice? Everywhere I look everyone just makes legs, or arms or some quadrupeds... is torso really that scary?
  • Quick Links