Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects Expressions › replaceSource and Effects

  • replaceSource and Effects

    Posted by Joe Chiro on October 2, 2020 at 9:18 pm

    I have a layer with a static image (png) and an effect (Bulge) applied to the layer. What I’m trying to do is replace the static image with another image, but I still want the effect to apply to the new image. My script is pretty simple and looks like this:

    // Load the replacement image

    var importOptions = new ImportOptions(File(“D:/Dev/AfterEffects/Scripts/Assets/Test.png”));

    var newImage = app.project.importFile(importOptions);

    // Replace the layer content

    testAVLayer.replaceSource(newImage, true);

    When I execute the script, the image is replaced and I still see the effect attached to the layer in the AE UI, but the new image is no longer modified by the effect. As a sanity check, I added some code to examine the layer after the replaceSource call:

    var fxLength = testAVLayer.effect.numProperties;

    for(var i=1;i<=fxLength;i++){

    var curFx = testAVLayer.effect(i);

    alert(curFx.name);

    }

    This code indicates that the Bulge effect is still attached to the layer.

    I’m a programmer by trade but very much a beginner with AE, so hopefully I’m missing something obvious. Thanks in advance for any help!

    Joe Chiro replied 5 years, 11 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    October 2, 2020 at 10:38 pm

    I just tried your code and it works for me (the replacement image is still modified by the effect). I’m not sure what could be happening. Maybe a cache or video driver issue–not sure…

  • Joe Chiro

    October 3, 2020 at 4:05 pm

    Thank you for taking a look. I’m guessing it’s something interesting on the project side. If I figure out I will update my post. Thanks again!

  • Joe Chiro

    October 5, 2020 at 7:11 pm

    And…I was missing something obvious: the new png was a different size than the one it was replacing, so it landed outside of the area where the effect was applied. Once I moved it into the correct area, the effect was of course visible.

    Thanks again for taking a look at this…I likely would have spent a lot of time staring at the code instead of looking at the project and learning some more about AE!

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