Parm Template Group Manipulation

The other day I had some idea for a tool. If I’m honest, I don’t remember what it was but part of it required that I had some temporary node with a color parameter. I started putting my idea together in Python and very quickly I got tripped up by the notion of parm template groups and parm templates. I had to study a little bit to detangle my knowledge and I was finally able to get how to put what I needed together. Unfortunately, I forgot what I needed that for. But at least I got the basic knowledge ready for the next time or if I remember what it was that I wanted to do in the first place. 

Here’s a little example of how to make a null at the object level, hide all of its default parameters and add my custom color parameter:

				
					import hou

#get obj levl
obj = hou.node("/obj")

#create null and set some properties
null = obj.createNode("null", "temp_null")
null.setColor(hou.Color((0,0,0)))
null.setSelectableInViewport(False)
null.setDisplayFlag(False)

#get parm template group
parm_grp = null.parmTemplateGroup()

#get its folders
templates = parm_grp.parmTemplates()

#iterate over folders
for t in templates:
    #hide folders
    t.hide(True)
    t_name = t.name()
    #replace these in the template group
    parm_grp.replace(t_name, t)
    
#make color parameter
color = hou.FloatParmTemplate("color", "Color", num_components = 3, 
    default_value= (1.0,0.0,0.0), look = hou.parmLook.ColorSquare, 
    naming_scheme = hou.parmNamingScheme.RGBA)
#append to group 
parm_grp.append(color)

#set parm template group on null
null.setParmTemplateGroup(parm_grp)


				
			

Here’s the resulting null with the custom parameter 🙂 

I needed to put this somewhere because I’m sure I will forget how to do this very soon. And with this, I conclude this entry. Until next time. 

Leave a Reply

Your email address will not be published. Required fields are marked *