• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Script crashing AE and I can't find out why

Community Beginner ,
Jun 07, 2020 Jun 07, 2020

Copy link to clipboard

Copied

Hey there, first time posting here.

Tried my best to find the solution for this on this forum and everywhere else but no success.

So, I'm trying to apply some effects to a layer and then duplicate it via a button in my script. The applying part works if not followed by the duplicate() part and vice-versa, but when I try to assemble the steps, it crashes AE.

Here's the code:

function example() {
    app.beginUndoGroup('Example');
    var thisComp = app.project.activeItem;
    applyFx(thisComp.selectedLayers[0]);
    thisComp.selectedLayers[0].duplicate();
    app.endUndoGroup();

    function applyFx(target) {
        var fx = target.property("ADBE Effect Parade");
        var timeDiff = fx.addProperty("ADBE Difference");
        timeDiff.property(2).expression = "thisLayer.source.frameDuration";
        timeDiff.property(4).setValue(1);
        var colorControl = fx.addProperty("ADBE Color Control");
        colorControl.property(1).expression = "t = thisLayer;\nt.sampleImage([0,0],[t.width,t.height],true);";
    }
}

 The only thing I can think of is the script tries to duplicate the layer while the effects are still being added.

Thanks for the help!

TOPICS
Crash , Error or problem , Scripting

Views

435

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jun 11, 2020 Jun 11, 2020

Alright, so if someone's having the same issue, just found the solution by the one and only Dan Ebberts over on creativecow.

Apparently, you can't add sampleImage expression to a layer by script and leave it there, but you can add it, harness the value and remove it later.

Cheers!

Votes

Translate

Translate
LEGEND ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

I tend to agree with your assessment. You may need to implement an extra check/ break and structure your script more.

 

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 08, 2020 Jun 08, 2020

Copy link to clipboard

Copied

Thanks for the answer!

Any suggestions on what would be best practice for this situation? I'm not really a programmer, just an enthusiast. Tried using async functions but I guess it's not compatible.

 

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 11, 2020 Jun 11, 2020

Copy link to clipboard

Copied

LATEST

Alright, so if someone's having the same issue, just found the solution by the one and only Dan Ebberts over on creativecow.

Apparently, you can't add sampleImage expression to a layer by script and leave it there, but you can add it, harness the value and remove it later.

Cheers!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines