Hi !
I'm new to MEL script and I can't figure out how to put a string in my line of code successfully without a synthax error.
I'm trying to create a script to transfer the ramp's positions and colors to another selected ramp. If I manualy enter the name of the ramps it works :
connectAttr -f rampMaster.colorEntryList[$Y].color rampReceiver.colorEntryList[$Y].color;
But when I try to make it automatic just by selecting them I write it like this and it doesn't work :
connectAttr -f ($sel[0]+".colorEntryList"+[$Y]+".color") ($sel[1]+".colorEntryList"+[$Y]+".color");
I also tried various other way to write it but I can't figure it out
Here's my script :
//Tranfering 3 ramp position and color from rampMaster to a second ramp
string $sel[] ;
$sel = `ls -sl`; //to get the names of the selected ramps (0,1,2,...)
int $Y = 0; // initialisation of Y for loop
while($Y <= 2) { //transfert des couleurs
connectAttr -f ($sel[0]+".colorEntryList"+[$Y]+".color") ($sel[1]+".colorEntryList"+[$Y]+".color");
connectAttr -f ($sel[0]+".colorEntryList"+[$Y]+".position") ($sel[1]+".colorEntryList"+[$Y]+".position");
$Y += 1; // loop 3 times
}
Thank you very much for the help and your time !