This script replaces all instances of one effect with another. But it doesn't work. Help!
Hi,
I'm using AE 2022, which is the maximum version I can use on the job I'm working on. I have this script which is intended to find all layers with Gaussian Blur in the active comp, turn off Gaussian Blur, then add Camera Lens Blur. The problem is it doesn't work. I don't get any error messages either. I'm curious to know where I went wrong.
// get the active composition
var comp = app.project.activeItem;
// check if a composition is active
if (comp != null && comp instanceof CompItem) {
// loop through all layers in the composition
for (var i = 1; i <= comp.numLayers; i++) {
// get the layer
var layer = comp.layer(i);
// check if the layer has effects
if (layer.effect) {
// loop through all effects applied to the layer
for (var j = 1; j <= layer.effect.numProperties; j++) {
// get the effect
var effect = layer.effect(j);
// check if the effect is Gaussian Blur
if (effect.displayName == "Gaussian Blur") {
// disable Gaussian Blur
effect.enabled = false;
// create a new Camera Lens Blur effect
var newEffect = layer.effects.addProperty("Camera Lens Blur");
// exit the loop since we've modified the layer
break;
}
}
}
}
} else {
alert("No composition is active.");
}
Ultimately, I'd like any Gaussian Blur "Blurriness" keyframes to be copied over to the Camera Lens Blur "Blur Radius", but reduced in value by 50% (or if there's no keyframes, then just copy the value over). I know that the look of each blur is different but I've found that this value gives the Camera Lens Blur a similar blur level. I know I could like up the two blurs with expressions and *0.5 but I'd rather have the keyframes baked in so I can choose to delete the Gaussian Blur later if needed.
