// Assigns a float to each face of a mesh.
// 1  Select the objects.
// 2  Execute this command, addFaceFloatPrimVar("mycolor", 0, 1);
  
global proc addFaceFloatPrimVar(string $shortname, float $minval, float $maxval) {
    string $sel[] = `ls -sl`;
    string $fullname = "rmanuF" + $shortname;
    for($current in $sel) {
        string $shapes[] = `listRelatives -s $current`;
        string $shape = $shapes[0];
        if(size($shape) == 0)
            continue;
        if(attributeExists($fullname, $shape) == 0) {
            addAttr -ln $fullname -nn $fullname -dt doubleArray -k 1 $shape;
            }
        // Data can only be added to the doubleArray via a string that begins
        // with the size of the array - in our case the number of faces of a
        // poly object.
        int $numFaces[] = `polyEvaluate -f $shape`;
        string $dataStr = $numFaces[0] + " ";
        for($n = 0; $n < $numFaces[0]; $n++)
               $dataStr = $dataStr + rand($minval, $maxval) + " ";
        eval("setAttr " + $shape + "." + $fullname + " -type doubleArray " + $dataStr);
        }
    }