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

Extendscript: Possible to check if layer is used in ANY effect?

Community Beginner ,
Aug 06, 2021 Aug 06, 2021

Hello lovely community,

 

I started writing a script which deletes layers which are not visible and not used in the composition.

 

Therefore the script has to check if the layer(name) is not used in ANY effect. I've been able to loop through all properties of the comps layers (including the effect properties) to find dropdowns in which the layer could be used. But I can only access the numerical value of the dropdowns, not the layer name, which I need to compare the layer names and find out if a layer can be deleted.

 

Does anyone has an idea on how to do this? 🙂 Or is it simply not possible to access textvalues of dropdowns by looping through all properties of layers.

 

Thank you so much!

Martin

TOPICS
Scripting
1.0K
Translate
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 Expert ,
Aug 06, 2021 Aug 06, 2021

I think a layer dropdown effect control always lists all the layers of the current composition and always lists them in the same order as they occur in the comp. So if you know that the second value of the dropdown is chosen, you know that it must be the second layer of the comp, right?

 

Another thing to keep in mind:

Layers might also be accessed by expressions. The source text of a layer could, for example, be linked to the name of another layer, and removing the layer will break the expression. Finding references to layers in expressions is probably nearly impossible to do properly.

If an expression contains
layer("my layer")

for example, you know that it uses a layer with name "my layer". But depending on what other code is around that statement, it could also be "my layer" of another comp. And if your expression contains something like

layer(i)

you would need to inspect the expression in more detail to figure out which value the variable i might have...

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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 ,
Aug 06, 2021 Aug 06, 2021

Hi Mathias,

 

thanks for your answer!

yes, the expression thing is a hard one. At the moment the script only detects "simple" expressions which is noch very convenient in the long run. To find a specific layer in all effects properties is also way more complex than I thought it would be...

 

Greetings from Hamburg to Hamburg 🙂

Translate
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 Expert ,
Aug 07, 2021 Aug 07, 2021
LATEST

Only looking for "simple" expressions is probably the only thing that makes sense in practive. Just be aware that it does not cover all cases - another uncovered case is iExpressions, which also produces expressions whose links are not really visible in the code.

 

Greetings from Stralsund 🙂

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Translate
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
LEGEND ,
Aug 06, 2021 Aug 06, 2021

As Mathias already stated, the layer dropdown controls are populated in the same order as the timeline itself. That would be pretty much the only way to verify if a layer is referenced anywhere. Mathias also makes some good points about inert layers that are seemingly not being used anywhere, but may be referenced in expressions. To add to that, it could even go so far as the reference actually being constructed inside the expression itself, in which case you don't even have a clean string to check against. I used to do such stuff in some of my old data graphics projects way back when. So technically there is never a clearcut 100% surefire way of being sure if a layer is actually not being used somewhere.

 

Mylenium

Translate
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