// Use this for assigning one float per selected object
// 1  Select the objects.
// 2  Execute this command, addConstFloatPrimVar("mycolor", 0, 1);
  
global proc addConstFloatPrimVar(string $shortname, float $minval, float $maxval) {
    string $sel[] = `ls -sl`;
    string $fullname = "rmancF" + $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 -k 1 $shape;
            }
        $value = rand($minval, $maxval);
        setAttr ($shape + "." + $fullname) $value;
        }
    }