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

Check if Layer Has Specific Effect Applied To It

Engaged ,
Sep 29, 2018 Sep 29, 2018

Copy link to clipboard

Copied

In extendscript, how can I check if a layer has a specific effect applied to it?  For example, suppose I want to check if a given layer has the "motion tile" effect applied to it.  Essentially, this is the pseudocode of what I want:

var layer_number = 1;

if (app.project.item(1).layer(layer_number) has motion tile applied)

{

  alert("It does!");

}

else

{

  add motion tile effect to app.project.item(1).layer(layer_number);

}

Can somebody please help me translate this pseudocode into real code that extendscript will recognize for After Effects?  Thanks.

TOPICS
Scripting

Views

2.0K

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 Expert , Sep 29, 2018 Sep 29, 2018

Something like this:

var myLayer = app.project.activeItem.layer(1);

var hasEffect = false;

for (var i = 1; i <= myLayer.property("Effects").numProperties; i++){

  if (myLayer.property("Effects").property(i).matchName == "ADBE Tile"){

    alert ("It does!");

    hasEffect = true;

    break;

  }

}

if (! hasEffect){

  myLayer.property("Effects").addProperty("ADBE Tile");

}

Dan

Votes

Translate

Translate
Community Expert ,
Sep 29, 2018 Sep 29, 2018

Copy link to clipboard

Copied

Something like this:

var myLayer = app.project.activeItem.layer(1);

var hasEffect = false;

for (var i = 1; i <= myLayer.property("Effects").numProperties; i++){

  if (myLayer.property("Effects").property(i).matchName == "ADBE Tile"){

    alert ("It does!");

    hasEffect = true;

    break;

  }

}

if (! hasEffect){

  myLayer.property("Effects").addProperty("ADBE Tile");

}

Dan

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
Engaged ,
Sep 30, 2018 Sep 30, 2018

Copy link to clipboard

Copied

LATEST

Perfect, thank you very much!

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