scp Posted July 18, 2008 Share Posted July 18, 2008 (edited) Hi all, I have been trying to automate adding keyframes at a frame specified by a control on the outside of a Digital Asset. I'm picking up the variable $freeze from the asset controls and then trying to input it into the chkey hscript at -f to specify the frame. Then I'm trying to add another keyframe the frame after in order to switch a switch. Here's the hscript I'm using wrapped within the general python script I'm using. I just can't get it to read the variables at integers for the frame numbers. hou.hscript("set here = oppwf;freeze = opparm -d $oppwf freeze1;opcf /switch1;chadd switch1 input;chkey -f $freeze -v 0 switch1/input;chkey -f $freeze+1 -v 15 switch1/input") Is it possible to use variables this way or can I incorporate variables created in Python into the Hscript string. If anyone knows or knows how to set keyframes with python directly that would be hugely appreciated. Thanks Simon Edited July 18, 2008 by scp Quote Link to comment Share on other sites More sharing options...
edward Posted July 19, 2008 Share Posted July 19, 2008 >>> print hou.node('/obj/torus_object1').asCode() ... # Code for keyframes on tx hou_keyed_parm = hou_node.parm("tx") hou_keyframe = hou.Keyframe() hou_keyframe.setTime(0) hou_keyframe.setValue(0) hou_keyframe.setSlope(0) hou_keyframe.setAccel(0.361111) hou_keyframe.setExpression("bezier()", hou.exprLanguage.Hscript) hou_keyed_parm.setKeyframe(hou_keyframe) hou_keyframe = hou.Keyframe() hou_keyframe.setTime(1.08333) hou_keyframe.setValue(0) hou_keyframe.setSlope(0) hou_keyframe.setAccel(0.333333) hou_keyframe.setExpression("bezier()", hou.exprLanguage.Hscript) hou_keyed_parm.setKeyframe(hou_keyframe) hou_keyframe = hou.Keyframe() hou_keyframe.setTime(2.08333) hou_keyframe.setValue(0) hou_keyframe.setSlope(0) hou_keyframe.setAccel(0.333333) hou_keyframe.setExpression("bezier()", hou.exprLanguage.Hscript) hou_keyed_parm.setKeyframe(hou_keyframe) ... 1 Quote Link to comment Share on other sites More sharing options...
scp Posted July 19, 2008 Author Share Posted July 19, 2008 Hi Thanks for the Python, I'm almost getting there with the hscript using $here with opparm. However it is returning more than I require. All I need is the last 8 as an integer so that I can use it as a frame value for setting my keyframes. set -g fog = `execute("opparm -d $here freeze1")` echo $fog opparm /obj/car/rollandcombine2 freeze1 ( 8 ) If anyone has any ideas to just get that 8 that would be great. Thanks Simon Quote Link to comment Share on other sites More sharing options...
scp Posted July 19, 2008 Author Share Posted July 19, 2008 Hi Edward Thanks again for the Python as it works great now! No more hscript for me. I must remember how good node.asCode is Thanks Simon Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.