// Malcolm Kesson
global proc addColorAttr(string $name, float $r, float $g, float $b) { 
    string $sel[] = `ls -sl`;
    for($current in $sel) {
        string $shapes[] = `listRelatives -s $current`;
        string $shape = $shapes[0];
        if(size($shape) == 0)
            continue;
        if(attributeExists($name, $shape) == 0) {
            addAttr -ln $name -sn $name -at "float3" -usedAsColor -k 1 $shape;
            $red = $name + "_r";
            $green = $name + "_g";
            $blue = $name + "_blue";
            addAttr -ln $red -at "float" -k 1 -parent $name $shape;
            addAttr -ln $green -at "float" -k 1 -parent $name $shape;
            addAttr -ln $blue -at "float" -k 1 -parent $name $shape;
            }
        setAttr ($shape + "." + $name) -type "float3" $r $g $b;
        }
    print("Added attribute \"" + $name + "\" with an RGB of " + $r + " " + $g + " " + $b + "\n");
    }