Skip to main content
Bram Hoekstra
Inspiring
October 25, 2021
Answered

Execute code when layer has a specific name

  • October 25, 2021
  • 1 reply
  • 294 views

Hi,

 

I'm Bram from the Netherlands. I'm building a script to efficiently build movie credits. 

 

I have a problem with creating various different scenarios for the sub-headings.

 

When the first layer created in the comp is a sub-heading it will get a scroll animation.

When a cutscene is above the to be create sub-heading it gets a certain amount of spacing and when there's a heading above it it gets a different amount of spacing.

The rest will get the same amount of spacing so I just to put that in the else{} section of the button.

 

But I don't get the button to function as I want it to. I tried to solve it with:

app.project.item(...).numLayers.name.subStr(..., ...) == "...";

app.project.item(...).numLayers.name == "...";

 

but none of the two work and I'm starting to loose my hope.

 

I've added a screenshot of what I got so far.

Does anybody have great suggestions on how to fix this?

 

Thanks in advance for your suggestions.

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

It seems like instead of .numLayers.name you'd want to use .layer(1).name (assuming you're looking at the first layer's name) or .layer(app.project.item(6).numLayers).name (to look at the last layer's name), or something similar.

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
October 26, 2021

It seems like instead of .numLayers.name you'd want to use .layer(1).name (assuming you're looking at the first layer's name) or .layer(app.project.item(6).numLayers).name (to look at the last layer's name), or something similar.

Bram Hoekstra
Inspiring
October 26, 2021

Thank you very much.

It worked!