// Use this for assigning one float per vertex
// 1  Select the objects.
// 2  Execute this command, addVertexFloatPrimVar("mycolor", 0, 1);
  
global proc addVertexFloatPrimVar(string $shortname, float $minval, float $maxval) {
    string $sel[] = `ls -sl`;
    string $fullname = "rmanvF" + $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 -sn $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 vertices of a
        // poly object.
        int $numVerts[] = `polyEvaluate -vertex $shape`;
        string $dataStr = $numVerts[0] + " ";
        for($n = 0; $n < $numVerts[0]; $n++)
            $dataStr = $dataStr + rand($minval, $maxval) + " ";
        eval("setAttr " + $shape + "." + $fullname + " -type doubleArray " + $dataStr);
        }
    }