Sunday, February 2, 2014

Circle control generator

This script:

generates a string variable containing all the currently selected joints, and for each joint selected...

  1. creates a circle 
  2. finds the shape node of the circle
  3. renames the circle as "selected joint" + shape
  4. creates a new variable for the renamed shape, and parents it to the selected joint
  5. deletes the transform node of the circle

You can run this script by copying this into the script editor and executing it. You can then either copy the circleAtJoint command to your shelf and run it from there, or type it into the script editor and execute the function name. Feel free to modify certain flags in the circle creation command, such as -r (radius) and -s (subdivisions).

global proc circleAtJoint()
{
 string $selectedJoints[] = `ls -sl`;
 for ($joint in $selectedJoints)
  {
  string $circle[] = `circle -c 0 0 0 -nr 1 0 0 -sw 360 -r 3 -d 3 -ut 0 -tol 0.01 -s 6 -ch 0`;
  string $circleShape[] = `listRelatives -s $circle[0]`;
  string $newShape = `rename $circleShape ($joint+"Shape")`;
  parent -r -s $newShape $joint;
  delete $circle[0];
  }
}


No comments:

Post a Comment