global proc blobbyFromMesh(string $path, float $scale)
{
// Assume there is only one selected poly shape
string  $obj[] = `ls -sl`;
int     $num[] = `polyEvaluate -v $obj[0]`; 
string  $shp[] = `listRelatives -shapes $obj[0]`;
string  $shape = $shp[0];
int     $fileid = fopen($path, "w");
  
// Setup the initial definition of the blobby.
fprint($fileid, "Blobby " + $num[0] + " [\n");
  
// Make each blob an ellipsoid and provide its array
// index. The indices monotonously increment by 16.
for($n = 0; $n < $num[0]; $n++)
    fprint($fileid, "1001 " + ($n * 16) + "\n");
  
// Specify the blending code "0" and the number of 
// blobs to blend.
fprint($fileid, "0 " + $num[0]);
  
// Specify the list of the indices from the first
// to the last blob.
for($n = 0; $n < $num[0]; $n++)
    fprint($fileid, " " + $n);
fprint($fileid, "]\n");
fprint($fileid, "[\n");
  
string    $row1, $row2, $row3, $row4;
float     $pos[];
string    $vert;
  
  
// Specify the transformations of each blob
for($n = 0; $n < $num[0]; $n++) {
  
    
    float $randScale = rand($scale-0.2,$scale);
  
    $vert = $shape + ".vtx[" + $n + "]";
    $pos = `pointPosition -local $vert`;
    $row1 = $randScale + " 0 0 0 ";
    $row2 = " 0 " + $randScale + " 0 0 ";
    $row3 = " 0 0 " + $randScale + " 0 ";
    $row4 = $pos[0] + " " + 
            $pos[1] + " " + 
            $pos[2] + " 1\n";
    fprint($fileid, $row1 + $row2 + $row3 + $row4);
    }
fprint($fileid, "]\n");
fprint($fileid, "[\"\"]\n");
  
// Close the archive file
fclose $fileid;
}
  
// Call the proc
//$path = getenv("HOME");
string $path = "/stuhome/vsfx419/ribs/blobbyHead.rib";
blobbyFromMesh($path, 1.2);