Forums › Adobe After Effects Expressions › Why does my script makes After Effects crash?
-
Why does my script makes After Effects crash?
-
Otávio Nascimento
December 10, 2022 at 10:31 pmHi,
I made a script UI with a ‘edit text’ and a button. It apply to selected layers a effect that is inside the ‘edit text’. But when typing the effect wrong and using the button to apply, After Effects freezes. What can I do to make After Effects not crash when trying to apply an effect that doesn’t exist?
function addEffect(findString)
{
if (myFindString == “”) {
return;
}
var curItem = app.project.activeItem.selectedLayers;
for (i=0; i
-
Otávio Nascimento
December 11, 2022 at 12:48 amfunction addEffect(myFindString)
{
if (myFindString == "") {
return;
}
var curItem = app.project.activeItem.selectedLayers;
for (i=0; i<curItem.length; i++){
var layerI = curItem[i].property("ADBE Effect Parade");
layerI.addProperty(myFindString);
}
} -
Dan Ebberts
December 11, 2022 at 12:52 amYou could capture the error using try/catch, like this example:
var myLayer = app.project.activeItem.layer(1);
var myEffect = "xxxx";
try{
myLayer.property("Effects").addProperty(myEffect);
}catch(err){
alert('"' + myEffect + '" is not a valid effect name.');
} -
Otávio Nascimento
December 12, 2022 at 8:34 pmThank you, thats what I needed.
Viewing 1 - 4 of 4 posts
Log in to reply.