Advertisement
Zoc

MEL: Transform polySplitRing to the middle

Zoc
Jun 25th, 2012
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.57 KB | None | 0 0
  1. // window - GUI
  2. {
  3.     string $window = `window -t "Az' Automated SplitEdgeRing"`;
  4.     rowColumnLayout;
  5.         floatFieldGrp -label "< 0.5" -precision 3 greaterThan;
  6.     floatFieldGrp -label "> 0.5" -precision 3 smallerThan;
  7.         button -l "Center" -command "funcChangeWeight(1)";
  8.     button -l "Non-Center" -command "funcChangeWeight(0)";
  9.     showWindow $window;
  10. }
  11.  
  12. proc funcChangeWeight(int $justCenter)
  13. {
  14.     // declare an array called $polySplitRings. Call ls to list
  15.     // all the polySplitRings in the scene
  16.     $polySplitRings = `ls -et polySplitRing`;
  17.    
  18.     if ($justCenter == 1)
  19.     {
  20.         //print "just Center \n"; // debug: show that the button was clicked
  21.         // loop through the array and set the weight to .5
  22.         for( $polySplitRing in $polySplitRings )
  23.         {
  24.             select -addFirst $polySplitRing ;
  25.             setAttr ($polySplitRing + ".weight") .5;
  26.             select -d $polySplitRing;
  27.         }
  28.     }
  29.     else
  30.     {
  31.         //print "Do not center \n"; // debug: show that the button was clicked
  32.         float $greaterThan = `floatFieldGrp -q -v1 greaterThan`;
  33.         float $smallerThan = `floatFieldGrp -q -v1 smallerThan`;
  34.         // loop through the array and set the weight to $greaterThan or $smallerThan
  35.         for( $polySplitRing in $polySplitRings )
  36.         {
  37.             float $fWeight = getAttr ($polySplitRing + ".weight");
  38.             //print ($fWeight + "\n"); // debug: show current weight attribute
  39.             select -addFirst $polySplitRing ;
  40.             if ($fWeight < 0.5)
  41.             {
  42.                 setAttr ($polySplitRing + ".weight") $smallerThan;
  43.             }
  44.             else
  45.             {
  46.                 setAttr ($polySplitRing + ".weight") $greaterThan;
  47.             }
  48.             select -d $polySplitRing;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement