Script to show/hide some layers
I'm working on a big multilingual AE project.
So far, I've managed the different language thanks to expression: I've created a controller layer in my top composition with 3 checkboxes (one per language) to control layers opacity. For instance here's the expression I have on a typical English title:
if(comp("Final").layer("Language").effect("English")("Checkbox") == 1) 100 else 0
It works as expected but now this project becomes too big for this method. I'm not sure what's going on in the background but now the render time for the whole project goes beyond 5 hours. If I manually disable the layers using the eyeball button in the timeline (instead of turning opacity to 0 with the expressions), my render time falls down to 1 hour.
So I'm wondering if a script could do the job.
Basically, I could rename the layers that need to be shown or hidden by adding the language code at the end of their names (EN for English, FR for French...). So the script will have to scan all the layers in the project and disable/enable the layers based on the last 2 characters of their names.
First big question: does a script can do that?
The first main problem I have is to find a way to get the script scanning through all the layers in all comps.
Yes it's possible, scripts are designed exactly for this kind of things.
You need to loop throw all project items, identify those that are compositions, then for each comp loop again over all layers, and do your stuff with each layer.
You can try this (on a test project...):
Thanks Xavier. This helps a lot.
In the meantime, I've found this page where I found a lot of help as well: http://leemscripts.tumblr.com/
The last script on the page (enable 3d switches for an entire hierarchy) is quite similar to what I want to do.
More than enough to start this script. I'll post news here...
I paste the script below.
I'm pretty sure that this script can be improved but it already does the job...