Sunday, February 19, 2017

Houville - adding params to a obj

Another one I keep forgetting... Here's how to add params to a node in houdini.
n = hou.node('/obj/geo1')
n.addSpareParmTuple(hou.IntParmTemplate('intParm','',1, default_value=(10,),min = 0, max = 20))
n.addSpareParmTuple(hou.FloatParmTemplate('floatParm','',1, default_value=(10,),min = 0, max = 20))

#define some multi line code.  Like a python script
code = """print 'some stuff'
print 'more stuffs'
print 'an\\\\' ting'"""

# is hidden is good for hiding code away
n.addSpareParmTuple(hou.StringParmTemplate('stringParm','',1,default_value=(code,), is_hidden=0))
n.addSpareParmTuple(hou.ButtonParmTemplate('Button','', join_with_next=0, script_callback='exec(hou.parm("stringParm").evalAsString())', script_callback_language=hou.scriptLanguage.Python))

And when you want to delete some parms, remember to get rid of the tuple.  You can access that easily like this:

And finally, if you don't want to add params one by one you can make a Parameter Template Group to then add as a lump later.
ptg = n.parmTemplateGroup()
ptg.append(hou.IntParmTemplate('intParm','',1, default_value=(10,),min = 0, max = 20))

Not quite sure yet why this is better, but I'll probably find out one day.

Monday, January 23, 2017

Retro bunker