Skip to main content
Participant
August 26, 2023
Answered

Re name layer as part of a script

  • August 26, 2023
  • 1 reply
  • 458 views

Hi, I am new to writing my own scripts for After Effects. To get my feet wet, I decided to make a simple script that changed the opacity of my layer as well as applied some effects with some predetermined values. As part of the script, I wanted the layer to change name.

I managed to get the script works as far as changing the opacity value and applying the effects as I want them to be applied, but it does not change the name of the layer. This is driving me nuts, as I thought it would be the easiest part to write. I have tried re-writing the script multiple times as well as investigating the reason behind its misbehaving with no success. Weirdly enough, the script does change the name of shape layers, but not any of the other types of layers.

I want to use this script with footage I import.

This is my script, any advice is appreciated. I am After Effects 2023

 

 app.beginUndoGroup("Bevel Process");

    var composition = app.project.activeItem;
    var bvlLayer = composition.selectedLayers[0]; //I want it to be applied to the layer I am currently selecting
    bvlLayer.property("ADBE Transform Group").property("ADBE Opacity").setValue([25]);
    bvlLayer.name = "BVL"; //this seems to be the line that is not working

    var bvlEffect = bvlLayer.Effects.addProperty("ADBE Bevel Alpha");
    bvlEffect.property(1).setValue(22);
    bvlEffect.property(4).setValue(1);

    var fbbEffect = bvlLayer.Effects.addProperty("ADBE Box Blur2");
    fbbEffect.property(1).setValue(5);
    fbbEffect.property(4).setValue(0);


 app.endUndoGroup();

 

This topic has been closed for replies.
Correct answer Dan Ebberts

It works for me. The only thing I can think of would be that you have the name column of the timeline set to Source Name. At first I thought that couldn't be the reason because you said it works for you with shape layers, but it turns out, that for shape layers, changing the name also apparently changes the source name.

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
August 26, 2023

It works for me. The only thing I can think of would be that you have the name column of the timeline set to Source Name. At first I thought that couldn't be the reason because you said it works for you with shape layers, but it turns out, that for shape layers, changing the name also apparently changes the source name.

Participant
August 27, 2023

Hi, thanks for the response. I did have the column in the timeline set to Source Name. Once I changed it to Layer Name, it worked perfectly.

 

Now I am interested in adding more lines to the script to set the column of the timeline to Layer Name to avoid any confusion for other people who might use the script.

 

Thanks again, I would not have caught it myself.