How can I create linked channels on a parm using python?

   2350   2   0
User Avatar
Member
1 posts
Joined: Dec. 2018
Offline
I'm trying to create and customize a node through a python script. I'm adding parms using the hou.parmTemplate() class and for one of the parameters I need to edit the Channel tab (see below).

I can't seem to find anything in the python documentation on how to do this; anybody know what the best solution would be?

Thanks!

Attachments:
image.png.33b25666562d1f644150cc9d4531bb7b.png (41.2 KB)

User Avatar
Member
1 posts
Joined: April 2019
Offline
Figured it out!
I initially copied everything over using parm templates, then if you access the node.Parms you can copy everything over with parm.set(otherparm), this copies the linked channels to the previously created parmTemplates.

Here's some example code where I'm switching the parent node's parameters based on the node selection from a dynamic menu

def OnSelected():
    #get value of menu
    menuParameter = hou.node("./").parm('pattern');
    selectedId = menuParameter.eval()
    selectedName = menuParameter.menuLabels()[selectedId]
    #set selected node display
    selectedNode = hou.node("./{}".format(selectedName))
    selectedNode.setDisplayFlag(True)
    selectedNode.setRenderFlag(True)
    
    node = hou.node("./")
    
    #add folder for options
    parmGroup = node.parmTemplateGroup()
    if parmGroup.find("options") != None:
        parmGroup.remove(parmGroup.find("options"))
    parmFolder = hou.FolderParmTemplate("options", "Options")
    
   
    #copy parm templates from selected node and add them to options folder
    parmTemplates = selectedNode.parmTemplateGroup().parmTemplates()
    for entry in parmTemplates:
        parmFolder.addParmTemplate(entry)      
    parmGroup.append(parmFolder)
    node.setParmTemplateGroup(parmGroup)
    
    #get actual parms (not templates) from selected node
    selectedParms = selectedNode.parms()
    newParms = node.parms()
    for newParm in newParms:
        for selectedParm in selectedParms:
            if newParm.name() == selectedParm.name():
                #matching template, set it to get linked channels
                newParm.set(selectedParm)
User Avatar
Member
3 posts
Joined: Sept. 2019
Offline
If you want set A to B, you can just use:

B.parm('some_parm').set(A.parm('some_parm'))

A link in 'some_parm' at A will be created
  • Quick Links