Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'aeq.project.getLayersDeep' method? #37

Open
runegan opened this issue Aug 21, 2017 · 0 comments
Open

Add 'aeq.project.getLayersDeep' method? #37

runegan opened this issue Aug 21, 2017 · 0 comments

Comments

@runegan
Copy link
Member

runegan commented Aug 21, 2017

Original report by Zack Lovatt (Bitbucket: zlovatt, GitHub: zlovatt).


We have aeq.getItemsDeep to create a flat arrayEx of nested items in a folder. Having this for layers in a comp (and precomps) would be good.

Pass in a comp, get a flat arrayEx of all layers in the comp and precomps.

/**
 * Returns an arrayEx of all layers in comp and precomps

 * @param  {CompItem} comp   The comp to flatten.
 * @return {aeq.arrayEx}     ArrayEx with Layer objects.
 */
function getLayersDeep (comp, returnArrayEx) {
    // The returnArrayEx param is so we can skip the converting to arrayEx when
    // recursing. It is not meant to be used outside of this function.
    var layers = [];

    aeq.forEachLayer(comp, function (layer) {
        if (aeq.isPrecomp(layer))
            layers.push.apply(layers, getLayersDeep(layer.source, false));
        else
            layers.push(layer);
    });

    // Skip converting to arrayEx when function is called by it self.
    if (returnArrayEx === false)
        return layers;

    return aeq.arrayEx(layers);
}
@runegan runegan added this to the 1.0 Release milestone Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant