-
Apply preset, set values
Hello friends,
my script should apply to any selected layer a preset and change the slider value of the preset.
So far so good. It works to the point where the slider value should be set.
It only change the values from the first layer.
How can I set the values from all layers? Thanks for your help.
if (app.project.activeItem != null || !app.project.activeItem instanceof CompItem){
var mySelectedLayers = app.project.activeItem.selectedLayers;
for (var i=0; i<mySelectedLayers.length; i++) {
var myLayer = mySelectedLayers[i];
var thisScriptPath = $.fileName;
var relativePath = thisScriptPath.substring(0, thisScriptPath.lastIndexOf(“/”));
var myPreset = File(relativePath+”/Assets/mySlider.ffx”);
var hasController = false;
for(var j=1; j<=myLayer.effect.numProperties; j++){
if(myLayer.effect.property(j).name == “mySlider”){
hasController = true;
};
};
if(!hasController){
myLayer.applyPreset(myPreset);
myLayer.effect(‘mySlider’).property(‘Slider’).setValue(100); // < This value should be changed.
myLayer.selected = false;
};
};
};