-
Script adding effect too many times.
I have a script to apply an effect to selected layers and turn off an expression on the applied effect. It works when I have the layers of interest selected. However, if I have layer transform properties (position scale, opacity, rotation) selected when I run the script, the effect is applied several times to the layer with the selected transform properties. Is there a way to only apply the effect once per layer if transform properties are selected with the layers?
function addPos(){
app.beginUndoGroup("TEST");
var myComp = app.project.activeItem;
var myLayers = myComp.selectedLayers;
var scriptFolderPath = File($.fileName).path;
var colorFolderPath = scriptFolderPath + encodeURI("/fp_presets");
var ffxFile = new File(colorFolderPath + encodeURI("/FP_position.ffx"));
myComp.applyPreset(ffxFile);
for (var i =0; i < myLayers.length; i++){
var myProp = myLayers[i].effect("FP - Position")("Position Offset");
myProp.expressionEnabled = false;
}
app.endUndoGroup();
}
addPos();