Jump to content

Transfer parmTuples?


Atom

Recommended Posts

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

code_for.gif

Edited by Atom
Link to comment
Share on other sites

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)

 

  • Like 1
Link to comment
Share on other sites

  • 1 year later...

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