//Makes a pile from whatever object is selected. global proc makePile() { string $lssl[] = `ls -sl`; string $group = `group -em -name "Pile_#"`; //// Tweak these variabes int $layerCount = 80; //How many objects per layer in your pile float $totalRadius = 7; //The radius of your pile float $height = 4; //The height of your pile int $rotateOnOff = 1; //Turn random rotation on or off float $bbMin[] = `getAttr ($lssl[0]+".boundingBoxMin")`; float $bbMax[] = `getAttr ($lssl[0]+".boundingBoxMax")`; float $layerThickness = $bbMax[1] - $bbMin[1]; //The amount of space for each layer of the pile $layerThickness = `abs $layerThickness`; int $layers = $height/$layerThickness; //How many object layers will there be? for ($ii = 0; $layers > $ii; ++$ii) { int $count = $layerCount / ($ii+1); for ($i = 0; $count > $i; ++$i) { float $rotX = rand(-180,180); float $rotY = rand(-180,180); float $rotZ = rand(-180,180); float $yPos = ($layerThickness*$ii); $radius = ((1 -`linstep 0 $height $yPos`) * $totalRadius); vector $sphereRand =unit(sphrand(1)) * $radius; string $dup[] = `duplicate $lssl[0]`; move -r ($sphereRand.x) $yPos ($sphereRand.z) $dup[0]; if($rotateOnOff == 1) { rotate -a $rotX $rotY $rotZ $dup[0]; } parent $dup[0] $group; } } }