First off, you don't have to set ty, tz or rx, as you're not changing anything.
The easiest way to do this would be to use two shelf buttons or hotkeys with the names changed. There is another more elegant solution which requires a bit more work however.
If you follow the cn_name_L/R naming convention, you can check if the object selected has L in it, and flip the attributes to R, and vice-versa. The code below will do this for you.
Simply select a side, and run the script - the selected object will be mirrored to the other side.
Code:
// get the active selection
string $sel[] = `ls -sl`;
string $nameTokenBuffer[];
// split the name of the first selected object by "_". L/R (should) be the last entry.
int $numTokens = tokenize($sel[0], "_", $nameTokenBuffer);
// extract the last entry.
string $selectedSide = $nameTokenBuffer[$numTokens - 1];
string $mirroredSize = "";
// set the side of the opposite control. L->R / R->L
if (tolower($selectedSide) == "l")
$mirroredSide = "R";
else if (tolower($selectedSide) == "r")
$mirroredSide = "L";
else
error("Unknown side \"" + $selectedSide + "\"");
// build the name of the opposite control using the mirrored side, and modify the values of its xform
setAttr("cn_Hand_" + $mirroredSide + ".tx", getAttr("cn_Hand_" + $selectedSide + ".tx") * -1);
setAttr("cn_Hand_" + $mirroredSide + ".ry", getAttr("cn_Hand_" + $selectedSide + ".ry") * -1);
setAttr("cn_Hand_" + $mirroredSide + ".rz", getAttr("cn_Hand_" + $selectedSide + ".rz") * -1);
Imagination is more important than knowledge.
Last edited by NextDesign; 09-06-2015 at 08:50 PM.