Creative Communities of the World Forums

The peer to peer support community for media production professionals.

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 pm

    Hi,

    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 am
    function 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 am

    You 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 pm

    Thank you, thats what I needed.

Viewing 1 - 4 of 4 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy