View Single Post
# 9 18-03-2004 , 10:19 PM
Subscriber
Join Date: Jan 2003
Location: Denmark
Posts: 338
Hi Kassun,

what you also can do, is make one Locator for the box, and one for each IKHandle on the hands... these two hand locators, would then be parented to the boxlocator...

so the box locator would be the master driver, and the two handlocators will follow when the box moves...

during a 3d course at the Animation Workshop in Viborg Denmark, I made this little script for a weight exercise, maybe you can use it... you would just have to change some names, but I have written it in the script... user added image

Code:
/*
''
''   Script Name: WeightExercise Setup v0.1
''   Author: Alex V. U. Strarup (3d@strarup.net)
''   Created: 4. Nov. 2003
''   Last Updated: 18. March 2004
*/

////////////////////////////////////////////////////////////////////////////////////////////
//
// this script was made to setup a weight exercise, during a 3D Animation Course at the
// AnimationWorkshop Viborg Denmark...
//
////////////////////////////////////////////////////////////////////////////////////////////
//
//  DESCRIPTION : setup script for creating a box constrain for a weight exercise...
//
////////////////////////////////////////////////////////////////////////////////////////////
//
//put the script in the script folder C:\Documents and Settings\~Your_User_Name~\Documents\maya\5.0\scripts
//
//  change LEFT_IK_HANDLE_NAME to the Name of your Left Hand Ik Controller...
//  and change Right_IK_HANDLE_NAME to the Name of your Right Hand Ik Controller...
//
//  if you are using Maya 4.5 you would also have to change the parentConstraint,
//  to a pointConstraint and a orientConstraint... e.g. -->
//  delete `pointConstraint DaBox BoxLocator`;
//  delete `orientConstraint DaBox BoxLocator`;
////////////////////////////////////////////////////////////////////////////////////////////
//
//How to call the script, just write...
// WeightExerciseSetup; in the commandline
//
////////////////////////////////////////////////////////////////////////////////////////////
//
//  Conditions : USE AT YOUR OWN RISK, NO RESPONSABILITIES DUE TO MALFUNCTION, JOB LOST, WHATEVER.
//
////////////////////////////////////////////////////////////////////////////////////////////

global proc WeightExerciseSetup()
{
//create the box...
  polyCube -w 5 -h 5 -d 5 -sx 1 -sy 1 -sz 1 -ax 0 1 0 -tx 1 -ch 1 -n "DaBox";
//move it...
  setAttr "DaBox.ty" 2.5;
  setAttr "DaBox.tz" 7;
//freeze the transformation...
  performFreezeTransformations 2;
  makeIdentity -apply true -t 1 -r 1 -s 1;
//move the pivotpoint of the box
  move 0 0 4.5 DaBox.scalePivot DaBox.rotatePivot ;

//create the Boxlocator which shall drive the hands...
  spaceLocator -p 0 0 0 -n "BoxLocator";
//contrain it to the box, and delete the constrain...
  delete `parentConstraint DaBox BoxLocator`;
//constrain the box to the locator......
  parentConstraint BoxLocator DaBox;
//make the boxlocator a bit bigger so it is easier to select and freeze translation...
  scale -r 2 2 2 BoxLocator;
  performFreezeTransformations 2;
  makeIdentity -apply true -t 1 -r 0 -s 0;

//create the lefthand locator...
  spaceLocator -p 0 0 0 -n "LH_Locator";
//contrain it to the left ikController, and delete the constrain...
//change LEFT_IK_HANDLE_NAME to the Name of your Left Hand Ik Controller...
  delete `parentConstraint LEFT_IK_HANDLE_NAME LH_Locator`;
//constrain the left ikController to the locator...
  parentConstraint LH_Locator LEFT_IK_HANDLE_NAME;

//create the righthand locator...
  spaceLocator -p 0 0 0 -n "RH_Locator";
//contrain it to the left ikController, and delete the constrain...
//change Right_IK_HANDLE_NAME to the Name of your Right Hand Ik Controller...
  delete `parentConstraint RIGHT_IK_HANDLE_NAME RH_Locator`;
//constrain the Right ikController to the locator......
  parentConstraint RH_Locator RIGHT_IK_HANDLE_NAME;

//parent the handlocators to the box locator
  parent LH_Locator RH_Locator BoxLocator ;
}
if you want to, you can then also lock the move and rotation attributes of your IKcontrollers, so you animate your arms/hands with their locators, and then when you have placed the hands on the box, you can animate them with the Box locator... here comes the code for the locking...

Code:
//lock the "move" attributes of the ikControllers...
select -r LEFT_IK_HANDLE_NAME.tx LEFT_IK_HANDLE_NAME.ty LEFT_IK_HANDLE_NAME.tz LEFT_IK_HANDLE_NAME.rx LEFT_IK_HANDLE_NAME.ry LEFT_IK_HANDLE_NAME.rz RIGHT_IK_HANDLE_NAME.tx RIGHT_IK_HANDLE_NAME.ty RIGHT_IK_HANDLE_NAME.tz RIGHT_IK_HANDLE_NAME.rx RIGHT_IK_HANDLE_NAME.ry RIGHT_IK_HANDLE_NAME.rz;
setAttr -lock true `ls -sl`;
select -cl;
here is the code to get the locators, just make a shelf, and make 3 shelf buttons, by dragging each command to the shelf... user added image

Code:
//Get the Box Locator...
select -r BoxLocator;

//Get the Left Hand Locator...
select -r LH_Locator;

//Get the Right Hand Locator...
select -r RH_Locator;
regards

Strarup


------------------------------------------------
Alex V. U. Strarup

One mistake can ruin it all...