Bone Mirroring - automate with Python?

   3977   3   0
User Avatar
Member
32 posts
Joined: Jan. 2017
Offline
Hello all,

I'm working on a tutorial for bone rigging for game meshes (stock houdini rigs/workflows on tutorials aren't game friendly). One part of the lesson is avoiding a -1 scale by manually mirroring bone nodes (the mirror tool in Houdini mirrors with a -1 scale which causes issues when sharing the rig with other programs).

Anyway I was wondering if there's a way to automate what I'm doing below, which is after copying the right side bones to the left, I multiply the bones' Y and Z axis by negative one to get a manual mirror while retaining a +1 scale. For the record, you CAN NOT freeze the transforms as the -1 scale Houdini applies is in the capture bone tab, not the transform tab.

I'm wondering if there's a way to automate this in Python. I do not know python but want to keep the graph CLEAN and free of for each loops and constraints and references to avoid problems when exporting to other software as that has been a source of frustration when exchanging Houdini rigs back and forth.

Would anyone know the code to create what I'm assuming is a for each loop with a * wildcard tageting bone nodes ending in _L, then create a variable for it's Y axis, create a variable for it's Z axis, then set the Y axis to the Y variable*-1, then set the Z axis to be the Z var *-1 ?




8 Minutes into the video is what I'm referring to…the link is set to start at 8 mins but isn't working.
Edited by GaryHanna - April 1, 2018 17:29:53
User Avatar
Staff
3464 posts
Joined: July 2005
Offline
you can make a quick shelf tool for this

make a new shelf tool and pop this into the script tab:

# get the selection
nodes = hou.selectedNodes()

for node in nodes:
    y = node.parm("ry").eval() * -1
    z = node.parm("rz").eval() * -1
    node.parm("ry").set(y)
    node.parm("rz").set(z)

this will change the “ry” and “rz” values on any selected node
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
User Avatar
Member
32 posts
Joined: Jan. 2017
Offline
goldfarb
you can make a quick shelf tool for this

make a new shelf tool and pop this into the script tab:

# get the selection
nodes = hou.selectedNodes()

for node in nodes:
    y = node.parm("ry").eval() * -1
    z = node.parm("rz").eval() * -1
    node.parm("ry").set(y)
    node.parm("rz").set(z)

this will change the “ry” and “rz” values on any selected node

THANKS!!!
User Avatar
Staff
3464 posts
Joined: July 2005
Offline

this script isn't the safest or using any ‘best practices’ so a little caution is needed…but it's a good way to get into using python to automate these kinds of things

looking forward to your tutorials!
Michael Goldfarb | www.odforce.net
Training Lead
SideFX
www.sidefx.com
  • Quick Links