jim c Posted December 4, 2013 Share Posted December 4, 2013 What would be the best way to go about updating the parms from left to right on a rig? FOr example, lets say you've got the rig set up and done an initial mirroring of the left side. Then you make some adjustments to some bones on the left side and want to mirror these adjustments (things like bone length, txyz or rxyz) over to the right side. As far as I know there's no shelf tools that do this or any utility scripts either? I started writing a script that does this but ran into some issues. The simple way of just globbing for nodes like "L_*" and then for each node found find the equivalent "R_" node and transfering params doesn't entirely cut it. Specifically, if on the left side you've "cleaned" or "frozen" the transform at the Parameter level (so everything is now moved to the pre-transform) how to you properly handle that on the other side? Quote Link to comment Share on other sites More sharing options...
edward Posted December 14, 2013 Share Posted December 14, 2013 To handle pre-transforms, th easiest way is to get the worldTransform(), manipulate the matrix, and then call setWorldTransform() on the other node. These are HOM methods in python. Quote Link to comment Share on other sites More sharing options...
jim c Posted December 14, 2013 Author Share Posted December 14, 2013 Thanks I think I have this sorted out now. It was easier than I thought, this is what I came up with def getFirstInput(node): inputs = node.inputs() if not inputs is None : if len(inputs) > 0 : return inputs[0] return None mirrorVec = hou.Vector3(1,0,0) mirrorVec = mirrorVec.normalized() mirror = hou.Matrix4() mirror.setToIdentity() mirror.setAt(0,0,1.0 - (2.0 * (mirrorVec[0]*mirrorVec[0]))) mirror.setAt(1,1,1.0 - (2.0 * (mirrorVec[1]*mirrorVec[1]))) mirror.setAt(2,2,1.0 - (2.0 * (mirrorVec[2]*mirrorVec[2]))) for n in hou.selectedNodes(): name = n.name() mirror_name = name.replace("L_", "R_", 1) parent = getFirstInput(n) mirrorP_name = parent.name().replace("L_", "R_", 1) mirrorP = hou.node(n.parent().path() + "/" + mirrorP_name ) mirrorNode = hou.copyNodesTo( (n,), n.parent() )[0] mirrorNode.setName(mirror_name) m = mirrorNode.worldTransform() mm = m * mirror mirrorNode.setWorldTransform(mm) mirrorNode.moveParmTransformIntoPreTransform() mirrorNode.parm('keeppos').set(1) mirrorNode.setFirstInput(mirrorP) mirrorNode.parm('keeppos').set(0) v = mirrorNode.origin() if v[0] > 0 : mirrorNode.parm("dcolorr").set(0) mirrorNode.parm("dcolorg").set(0) mirrorNode.parm("dcolorb").set(1) mirrorNode.setColor(hou.Color((0,0,1))) elif v[0] < 0 : mirrorNode.parm("dcolorr").set(1) mirrorNode.parm("dcolorg").set(0) mirrorNode.parm("dcolorb").set(0) mirrorNode.setColor(hou.Color((1,0,0))) mirrorNode.moveToGoodPosition() 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.