Skip to main content
georgej10572380
Participant
July 3, 2019
Answered

Controlling Solo layers across multiple compositions

  • July 3, 2019
  • 1 reply
  • 858 views

Hey there, I was wondering whether someone could help with this.

I have a large project which is running very slowly because of the number of precomps I'm having to work with. In a bid to tackle this I have created simple versions of the design which I am soloing in the respective compositions to work with while animating.

Is there a way of me controlling these layers from one point in my main composition? A long shot I know, but any advice would be much appreciated.

This topic has been closed for replies.
Correct answer Justin Taylor-Hyper Brew

Thanks Justin, really appreciate your help!

Each of the red outlined components of my design above are separate pre-comps which all have different parts of a technical process happening within them. So I guess that means I need control over the subcomps contained within that main composition I have screen shot?


To solo all subcomps, something like this will work:

function soloRedLayers(layers){

    var numSolo = 0;

    for (var i = 0; i < layers.length; i++) { 

        var layer = layers[i+1]; 

        var shouldSolo = false;

        if(layer.source instanceof CompItem){

            // if layer is comp, then inspect children

            var newSoloed = soloRedLayers(layer.source.layers);

            if(newSoloed > 0){

                // if contains soloed layers, then solo precomp

                shouldSolo = true;

                numSolo++

            }

        }

        else{

            // if layer is labelled red then solo

            shouldSolo = layer.label == 1; 

            numSolo++;

        }

        layer.solo = shouldSolo; 

    } 

    return numSolo;

}

soloRedLayers(app.project.activeItem.layers);

Then to unsolo all your layers, you'll need to run something like this:

function unSoloLayers(layers){

    for (var i = 0; i < layers.length; i++) { 

        var layer = layers[i+1]; 

        layer.solo = false; 

        if(layer.source instanceof CompItem){

            // if layer is comp, then inspect children

            unSoloLayers(layer.source.layers);

        }

    } 

}

unSoloLayers(app.project.activeItem.layers);

You'll need to run both of these commands from the main comp.

1 reply

Mylenium
Legend
July 3, 2019

Layer switches can only be addressed with scripts, not expressions, but unless you follow e.g. a specific naming convention that would uniquely identify those layers, even that would be pointless. Long and short: It's probably not going to solve your immediate issues, but you may explore this for future projects.

Mylenium

georgej10572380
Participant
July 3, 2019

Thank you for your responce!

I feel like it would be easy for me to follow a naming convention if that is the way to do it. I have attached a screen shot of my 'rig'. The red outlined parts are the elements which I have soloed to help my previews. How would I go about controlling those layers with a script?

Thanks,

Justin Taylor-Hyper Brew
Community Expert
Community Expert
July 3, 2019

There's a lot of ways you could go about this, with scripting something like checking if the layer is labeled red and soloing it would work:

var layers = app.project.activeItem.layers;

for (var i = 0; i < layers.length; i++) {

    var layer = layers[i+1];

    // check if layer is labelled red

    var shouldSolo = layer.label == 1;

    layer.solo = shouldSolo;

}

Or check out  Labels 3 https://aescripts.com/labels/  which lets you select all layers by a label and then you can hit solo or use a keyboard shortcut for it.