Atom Posted September 9, 2016 Share Posted September 9, 2016 (edited) Hi All, I am looking for a python way to transfer existing rotation tuples in one node into a new folder in the parameter interface of another node. In this case I have a FBX subnet with null controls inside. The only way I can leverage the Pose Library is if the rotation values for every null in the subnet are "promoted" up to the subnet level (the Pose Library can not see inside the subnet, only the top level) I am looking for a way to programmatically create this connection between the two nodes as shown manually in the animated GIF. I have some code that creates a new parameter on a node but I am not sure how to transfer an existing parameter. original_rx = hou.FloatParmTemplate( "original_rx", "Original RX", 1, default_value=([n.parm("rx").eval()])) n.addSpareParmTuple(original_rx, in_folder=(["Transform"]), create_missing_folders=True) Looking for code to do this... Edited September 9, 2016 by Atom Quote Link to comment Share on other sites More sharing options...
MrScienceOfficer Posted September 9, 2016 Share Posted September 9, 2016 (edited) It's just creating a parm and setting the ch() expression. Something like " parm.setExpression("ch(" + node.relativePathTo(parent_node) + ")" ) " would achieve the same results. Edited September 9, 2016 by MrScienceOfficer Quote Link to comment Share on other sites More sharing options...
Atom Posted September 11, 2016 Author Share Posted September 11, 2016 Thank you for the reply, that lead me to write a short script to migrate multiple node rotation values within a subnet to the upper level subnet. # Node names inside the subnet which contain a rotation value. node_names = ["Neck", "Spine1","etc..."] def promoteParameters(node_path): target_node = hou.node(node_path) if target_node != None: for i,node_name in enumerate(node_names): n = hou.node('%s%s' % (node_path,node_name)) if n != None: target_parm_name = "r_%s" % node_name try: v = target_node.parm(target_parm_name).eval() should_create = False except: should_create = True if should_create: # Sometimes a FBX will come in with keyframes on fields, remove them. n.parm("rx").deleteAllKeyframes() n.parm("ry").deleteAllKeyframes() n.parm("rz").deleteAllKeyframes() rx = n.parm("rx").eval() ry = n.parm("ry").eval() rz = n.parm("rz").eval() temp_axis = hou.FloatParmTemplate(target_parm_name, "Rotate %s"%node_name, 3, min=0.0, max=360.0, default_value=([rx,ry,rz])) target_node.addSpareParmTuple(temp_axis, in_folder=(["PoseControls"]), create_missing_folders=True) # Set up an expression so the NULL inside the subnet will fetch it's value from the subnet level. n.parm("rx").setExpression('ch("../%sx")'%target_parm_name) n.parm("ry").setExpression('ch("../%sy")'%target_parm_name) n.parm("rz").setExpression('ch("../%sz")'%target_parm_name) # Autoscope these new paramters so the Pose Library will detect them. target_node.parm("%sx"%target_parm_name).setAutoscope(True) target_node.parm("%sy"%target_parm_name).setAutoscope(True) target_node.parm("%sz"%target_parm_name).setAutoscope(True) else: print "skipping, parameter [%s] already exists." % target_parm_name else: print "[%s%s] not found." % (node_path,node_name) else: print "[%s] node path not found." % node_path # Call function. promoteParameters(subnet_root_path) 1 Quote Link to comment Share on other sites More sharing options...
reinatch Posted March 30, 2018 Share Posted March 30, 2018 hey Atom, thanks for the script, I'm trying to get into animation with python,( really a beginner ), this script is gold for me I'm wondering how it be if i don't want do deleted the existing animation keyframe? 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.