Python promote parameter

   2221   2   1
User Avatar
Member
33 posts
Joined: May 2015
Offline
Hi,

I am trying to mimic the Hda's ‘Promote Parameter’ behavior, using python.

I've been able to add hda's parameters, with default values, using:

oParmTemplate = hou.StringParmTemplate(…
oParmTemplate = hou.ButtonParmTemplate(…
oHdaDefefinition.setParmTemplateGroup(oParmTemplateGroup)

But I can't find how to add a ‘Linked channels’, in the channels section (Edit Operator Type Properties –> Parameter).

Is it possible to do so using python?

Thanks,
Jonathan

Attachments:
Screenshot-239.png (22.4 KB)

User Avatar
Member
1 posts
Joined: July 2020
Offline
I know this is an old post, but I had to do something similar and took the approach below:

"""
Suppose we want to promote the parameters tx,ty and tz from a node right inside the hda
"""
# node: a node right inside the hda
hdaDef = node.parent().type().definition() # get HDADefinition
parmTemplateGroup = hdaDef.parmTemplateGroup()

targetParmTuple = node.parmTuple("t") # get parmTuple for t (which holds tx,ty,tz)
targetParmTemplate = targetParmTuple.parmTemplate() 
parmTemplateGroup.append(targetParmTemplate)
hdaDef.setParmTemplateGroup(parmTemplateGroup, rename_conflicting_parms=True) # update HDA

for parm in targetParmTuple: # link node parameters to HDA parameters
    parm.setExpression(f'ch("../{parm.name()}")')

# XXX: Might need some more tweaking on the targetParmTemplate in some cases
# XXX: the HDA needs to be saved manually after the script

Houdini Version: 19.0.383 (Python 3, which is now the default )
User Avatar
Member
900 posts
Joined: Feb. 2016
Offline
thanks for sharing!
I always struggle when I need to work with parmtemplates
  • Quick Links