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!
How can I create linked channels on a parm using python?
2324 2 0- zragozzi
- Member
- 1 posts
- Joined: 12月 2018
- Offline
- pajamajama
- Member
- 1 posts
- Joined: 4月 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
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)
- allenzhang1123
- Member
- 3 posts
- Joined: 9月 2019
- Offline
-
- Quick Links