for finding closest.
I put all the main objects in an array, and all the ones that you want to find in a second array
then for each in the first Array, I get its worldspace position using xform -q -rp -ws
and then iterate through all the Second array positions. finding the smallest difference each time, and each time
I get a smaller distance, I make that the answer.
at the end. you should be left with the object that is the shortest distance away.
also at that point, i remove it from the second array, so it doesn't keep getting checked.
granted this isn't the most efficient way, but it does work.
and from that I create a new array that is a matched pair
pairArray[0] = gorilla1Base ; pairArray[1] = gorilla1TGT ; pairArray[2] = gorilla2Base ; pairArray[3] = gorilla2TGT ;
( obviously the names won't line up.. but I do recommend renaming them to match .. it just helps so much )
often, I will match the target with the same name as the base. but with just TGT added,
this makes it easier to script and find. and it's always easier to add to a name, then search, parse and replace.
ie: string $basename = "gorilla" ; string $targetname = ($basename + "TGT");
so , lets say all the names line up like above..
now you can run a simple loop script to make the blendShapes
for ($base in $sel)
string $bss[] = `blendShape -n ($base + "_blendShape") ($base + "TGT") $base`;
Add your channel to the base and connect the attributes
connectAttr ($base + ".blendChannel") ($bss[0] + ".w[0]");
hope that helps
-=s