Link Comp name to Color Palette
Download Project Files
//01Ray Color 2.0
n = thisComp.name.split(",")[1];
rayColorPalette = comp("Ray - Product Colors");
rayColorSwatch = eval(n);
try{ rayColorPalette.layer(1)(4)(rayColorSwatch)(1); }catch(e){ value; }
Bonus Tip:
You can also use thisLayer.name instead of thisComp.name
Alternatively solution
You can also give the color control properties in the color palette a name and then use that name in your comp or layer to call up the right color.
Just remove "eval()" from your expression as you're now working with a string instead of numbers.
Here I've named my effect in the color palette Red. When I name the end part of my comp Product,Red the expression will go find that red color from my palette.
Comp name is: Project,Red
//01Ray Color 2.0
n = thisComp.name.split(",")[1];
rayColorPalette = comp("Ray - Product Colors");
rayColorSwatch = n;
try{ rayColorPalette.layer(1)(4)(rayColorSwatch)(1); }catch(e){ value; }