Check if Layer Has Specific Effect Applied To It

Contributor ,
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.

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

TOPICS
Scripting

Views

589

Likes

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

Check if Layer Has Specific Effect Applied To It

Contributor ,
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.

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

TOPICS
Scripting

Views

590

Likes

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

Likes

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
Reply
Loading...
Sep 29, 2018 0
Contributor ,
Sep 30, 2018

Copy link to clipboard

Copied

Perfect, thank you very much!

Likes

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
Reply
Loading...
Sep 30, 2018 0