Non-linear blendshape shelf tool script

   1393   0   1
User Avatar
Member
402 posts
Joined: June 2014
Offline
Hello again,

Just airing out another little script for a shelf tool that quickly sets up non-linear (quadratic interpolation) blendshapes. Can be a handy technique for eyelids –
1) create fully closed and half-closed blendshapes, plug them into your blenshapes SOP.
2) Then select the blendshape SOP and run the shelf tool
3) select the half-closed shape as your ‘intermediate shape’ (the first prompt) and then your full closed shape from the second prompt

Hope it's useful to someone out there

blend_nodes = hou.selectedNodes()

if len(blend_nodes) < 1 or blend_nodes[0].type().name() != "blendshapes":
    raise hou.Error("Please select a blendshapes node...")
else:
    blend_node = blend_nodes[0]


blend_list = list(p.alias() for p in blend_node.globParms("blend*"))

idx = hou.ui.selectFromList(
    blend_list,
    message="Select intermediate shape...",
    exclusive=True
)[0]

first = blend_node.parm(blend_list[idx])
blend_list.pop(idx)

idx = hou.ui.selectFromList(
    blend_list,
    message="Select final shape...",
    exclusive=True
)[0]

second = blend_node.parm(blend_list[idx])

t_parm_name = hou.ui.readInput("Please enter a name for the new drive parameter")[1]

first_exp = '-4 * (pow(ch("' + t_parm_name + '"), 2)) + 4 * (ch("' + t_parm_name + '"))'
second_exp = '2 * (pow(ch("' + t_parm_name + '"), 2)) - ch("' + t_parm_name + '")'

spare = hou.FloatParmTemplate(t_parm_name, t_parm_name.replace("_", " ").capitalize(), 1, max=1.0)
blend_node.addSpareParmTuple(spare)

first.setExpression(first_exp, language=hou.exprLanguage.Hscript)
second.setExpression(second_exp, language=hou.exprLanguage.Hscript)
Henry Dean
  • Quick Links