Jump to content

Multiparm Editing in Python


Recommended Posts

I am working to build a tool which contextualizes updates options in a multiparm block based on an option selected in the block itself. I have been able to get ahold of the information for which index in the multiparm everything is going and have been able to extract information just fine, but I cannot seem to update the UI. I really feel like I am just missing a function somewhere in the documentation. Right now I'm essentially doing this to update what I have now:

def load():
    node = hou.pwd()
    ptg = node.parmTemplateGroup()
    baseAttribs = ["list", "pulled", "in", "from", "elsewhere"]
    multiparm = hou.FolderParmTemplate("attrib", "Attrib Item", folder_type = hou.folderType.MultiparmBlock)
    collapsibleFolder = hou.FolderParmTemplate("settings#", "Settings", folder_type = hou.folderType.Collapsible)
    attribList = hou.MenuParmTemplate("root_attribs#", "Select Attribute", tuple(baseAttribs), menu_labels=tuple(baseAttribs), script_callback="hou.phm().attribType(kwargs)", script_callback_language=hou.scriptLanguage.Python, menu_use_token=True)
    collapsibleFolder.addParmTemplate(attribList)
    multiparm.addParmTemplate(collapsibleFolder)
    multiparm.setDefaultValue(1)
    ptg.appendToFolder(ptg.findFolder("JSON Settings"), multiparm)
    node.setParmTemplateGroup(ptg)

def attribType(kwargs):
    node = hou.pwd()
    p = kwargs["parm"]
    parent = p.parentMultiParm()
    multiParmIndex = int(kwargs['script_multiparm_index'])
    menuIndex = int(kwargs['script_value'])
    container = parent.parmTemplate().parmTemplates()[0]
    selected = p.menuItems()[menuIndex]
    a = hou.LabelParmTemplate("test#", f"Testing that this works {multiParmIndex} {selected}")
    container.addParmTemplate(a)

I know what the name should be and I have the correct multiparm index from within kwargs, which is amazing. So how can I put things into the collapsible folders? For the first entry I know I have the settings1 folder and I want to add in that label, but I cannot seem to figure out how to do that.

Link to comment
Share on other sites

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