Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions problem linking gaussian bluriness to other layer’s slider

  • problem linking gaussian bluriness to other layer’s slider

    Posted by Steve Sierra on April 26, 2017 at 7:57 am

    Hi,

    I am trying to link a layers gaussian blur bluriness to another layer’s slider control via scripting.
    Here’s my code :

    var curLayer = curComp.selectedLayers[0];
    var curName = curLayer.name;
    var copyLayer = curLayer.duplicate();
    var copyFX = copyLayer.property(“ADBE Effect Parade”);
    var copyBlur = copyFX.addProperty(“ADBE Gaussian Blur”);
    var copyBluriness = copyBlur.property(“ADBE Gaussian Blur-0001”);
    …..other code…….
    copyBluriness.expression = ‘thisComp.layer(“‘ + curName + ‘”).effect(“Blur”)(“Slider”)’;

    It returns an invalid object…
    Can anyone tell me what I’m doing wrong ? Am I forgetting a “.value” somewhere ?

    Thanks
    😉

    Xavier Gomez replied 9 years ago 2 Members · 6 Replies
  • 6 Replies
  • Xavier Gomez

    April 26, 2017 at 8:13 am

    It looks ok, unless the selectedLayers[0] does not have a Slider Control named “Blur”.

    Xavier

  • Xavier Gomez

    April 26, 2017 at 8:41 am

    In previous post i was only looking at the expression code, but.. just thinking now: when expressions break, there is no such message as “Object is invalid”, hence i suppose that you get the error inside your script, not later in after effects.

    Therefore it might be coming from your “other code”.
    And it be so if ‘other code’ messes up with the effects stacks in copyLayer (for instance, if other effects are added, then the copyBlur variable point to a property that is no longer valid, and you have to redefine it).

    Xavier

  • Steve Sierra

    April 26, 2017 at 8:58 am

    Hi Xavier,

    Thanks for your quick replies.
    I think you are right…
    Immediatly after creating the Gaussian blur, I create a Bevel Alpha effect. If I don’t create it, my code works fine.

    If I understand what’s going on, my code is referencing the Gaussian blur effect by index ? And when I create the bevel, it’s index becomes [1] in the effects group ?

    So, in order to keep both effects, I have to reference the blur effect by index once I have finished adding all effects to this layer ? Can I reference it by name ?

    Thanks again !
    😉

  • Xavier Gomez

    April 26, 2017 at 11:25 am

    Name or index will work, take the one that is most suited to your needs.
    It works this way:

    var myFx1 = myLayer.effect.addProperty(matchName1);
    var idx1 = myFx1.name;
    var idx1 = myFx1.propertyIndex;
    var myFx2 = myLayer.effect.addProperty(matchName2);

    // at this stage, the variable myFx1 point to an invalid object

    myLayer.effect.property(matchName1); // the first effect in effect stack that has the same matchName
    myLayer.effect.property(name1); // the first effect in effect stack that has the same name
    myLayer.effect.property(idx1); // should point to the same property as myFx1

    Xavier

  • Steve Sierra

    April 26, 2017 at 2:09 pm

    I see…
    Too bad you can’t reference it directly by name when you create it.

    Thanks again, this is pretty important to know if you don’t want to be staring at your invalid object for hours… ????

    Cheers !

  • Xavier Gomez

    April 26, 2017 at 2:14 pm

    I messed up my previous post. “var idx1 = myFx1.name;” should actually be:

    var name1 = myFx1.name;

    Xavier

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