Jump to content

python - how to add a parm template goup to an existing folder


jumper

Recommended Posts

Hi,

I am having trouble figuring this one out ...

I have a node "renderNode1" with a folder called "Passes" and I have made a new set of ui buttons etc with the following code ..

hou_parm_template_group = hou.ParmTemplateGroup()

hou_parm_template2 = hou.ToggleParmTemplate("passOn", "Pass On", default_value=True, disable_when="")

hou_parm_template2.setJoinWithNext(True)

hou_parm_template3 = hou.StringParmTemplate("name", "Name", 1, default_value=(["temp1"]), naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.Regular, menu_items=([]), menu_labels=([]), icon_names=([]), item_generator_script="", item_generator_script_language=hou.scriptLanguage.Python, menu_type=hou.menuType.Normal)

hou_parm_template3.setJoinWithNext(True)

hou_parm_template_group.append(hou_parm_template2)

hou_parm_template_group.append(hou_parm_template3)

how do I add these to an existing folder called "Passes"..

n = hou.node('/out/renderNode3')

n.setParmTemplateGroup(hou_parm_template_group)

adds the new ui elements into a new folder called spare... I want to add them into an existing folder any ideas?

cheers

Stephen

Link to comment
Share on other sites

  • 2 weeks later...

Hey,

why don't you try to use addSpareParmTuple instead of setParmTemplateGroup

that should solve your problem

example :

    node = hou.node(".")
    myParms = hou.FolderParmTemplate("folder", "Physical",(
                hou.FloatParmTemplate("mass", "Mass", 1),
                hou.FolderParmTemplate("folder1", "Physical",(
                    hou.FloatParmTemplate("mass1", "Mass", 1),
                    hou.FloatParmTemplate("density1", "Density", 1),
                )),
            ))

    myNewParms = hou.FolderParmTemplate("folder2","Physical" , (
               hou.FloatParmTemplate("mass2", "Mass", 1),
               hou.FloatParmTemplate("density2", "Density", 1),
            ))
    myParms.addParmTemplate(myNewParms) 

    node.addSpareParmTuple(myParms ,('myFolder',))

I hope that helps

Edited by geo
Link to comment
Share on other sites

What you want to do is get the existing Parm Template Group from your node and then add the new parameters into that folder. You then set that group back to the node and you are all set.

You can also do it the pre Houdini 11 way as geo suggests by manually adding the tuples to the existing folder, however I'd personally recommend doing it the Parm Template Group method now since it generally works a lot better and offers more in the way of customizability.

node = hou.node("/out/ropname")
ptg = node.parmTemplateGroup()

hou_parm_template2 = hou.ToggleParmTemplate("passOn", "Pass On", default_value=True, disable_when="")
hou_parm_template2.setJoinWithNext(True)

hou_parm_template3 = hou.StringParmTemplate("name", "Name", 1, default_value=(["temp1"]), naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.Regular, menu_items=([]), menu_labels=([]), icon_names=([]), item_generator_script="", item_generator_script_language=hou.scriptLanguage.Python, menu_type=hou.menuType.Normal)
hou_parm_template3.setJoinWithNext(True)

target_folder = ("Passes",) // or whatever your folder is.
ptg.appendToFolder(target_folder, hou_parm_template2)
ptg.appendToFolder(target_folder, hou_parm_template3)
node.setParmTemplateGroup(ptg)

I see you are just adding spare parameters here, but one big advantage of the template group method is for when you are adding parameters to digital asset definitions (hou.HDADefiniton). When you call hou.HDADefinition.addSpareParmTuple(), each time you call this function to add a parm template it requires Houdini to make an I/O call to write the new parameter to the definition and save it. If you are adding a lot of parameters this can be very slow since you constantly have to keep saving the asset. When you call hou.HDADefintion.setParmTemplateGroup() you can add all the parms at once and only generate a single write. Also, the template groups allow you to have access to the parameter information and layout without an instance of a node.

Edited by graham
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...