//James Parks //04-28-02 //jpMirR.mel //written in response to a query on highend3d.com //This script takes two objects and mirrors their movements //across the selected global axes. It does this by //connecting the second object's transform attributes to //the first's. Consequently when the objects are mirrored //you can only translate the first. //Known Limitations //1.) I'd like to be able to move the second object during the // mirror and have the first respond, but that gets cyclic /////////////////////////// //To use, select the two objects that you want //mirrored and then run this script. /////////////////////////// //Feel free to mess with my code. If you do something intersting //with it send me an email at arcsecond@hotmail.com global proc mirR() { string $objs[] = `ls -sl`; if (`size($objs)` != 2) error "Wrong number of objects selected. Script only works with 2 objects."; int $xCheck = `checkBoxGrp -query -value1 axesGrp`; int $yCheck = `checkBoxGrp -query -value2 axesGrp`; int $zCheck = `checkBoxGrp -query -value3 axesGrp`; int $xMirror; int $yMirror; int $zMirror; string $nodeName = `createNode "multiplyDivide" -n "tempMD"`; //connect the first object to the MD's first inputs connectAttr ($objs[0] + ".tx") ($nodeName + ".i1x"); connectAttr ($objs[0] + ".ty") ($nodeName + ".i1y"); connectAttr ($objs[0] + ".tz") ($nodeName + ".i1z"); //connect the MD's outputs to the second object connectAttr ($nodeName + ".ox") ($objs[1] + ".tx"); connectAttr ($nodeName + ".oy") ($objs[1] + ".ty"); connectAttr ($nodeName + ".oz") ($objs[1] + ".tz"); if ($xCheck == 0) $xMirror = 1; else $xMirror = -1; if ($yCheck == 0) $yMirror = 1; else $yMirror = -1; if ($zCheck == 0) $zMirror = 1; else $zMirror = -1; setAttr ($nodeName + ".i2x") $xMirror; setAttr ($nodeName + ".i2y") $yMirror; setAttr ($nodeName + ".i2z") $zMirror; select $objs[0]; } global proc unMirR() { delete "tempMD*"; } global proc jpMirR() { string $winName = "jpMirR"; if (`window -exists $winName`) deleteUI $winName; window -t "Motion Mirror" -wh 190 115 $winName; frameLayout -label "Mirror Options" -borderStyle "in" -cll 0 -li 10 -la "center" -mw 5 -mh 5 -w 500 ; columnLayout; checkBoxGrp -numberOfCheckBoxes 3 -label "Mirror Axes" -labelArray3 "X" "Y" "Z" -value1 1 -value2 0 -value3 0 -cw 1 75 -cw 2 30 -cw 3 30 -cw 3 30 -cal 1 "left" -cal 2 "left" axesGrp ; button -w 75 -l "MirrorMe" -c "mirR()"; button -w 75 -l "unMirror All" -c "unMirR()"; showWindow $winName; } jpMirR;