1

I have a function like this:

  function selectLayersOfType_inContainer( layerType, containerLayer ) {

        // Filter layers using NSPredicate
        var scope = containerLayer.firstObject().children(),
            predicate = NSPredicate.predicateWithFormat( "(className == %@)", layerType ),
            layers = scope.filteredArrayUsingPredicate( predicate );

        // Loop through filtered layers and select them
        var loop = layers.objectEnumerator(),
            layer;
        while ( layer = loop.nextObject() ) {
            // [ layer select: true byExpandingSelection: true ]
            console.log( layer )
        }
        log( layers.count() + " " + layerType + "s selected" )
    }

The function iterates through selected item and returns only MSLayerGroup-s. But I need to know one more thing - which of groups is higher in layers hierarchy or which one is parent/children. So how can I find out what it is "Child1.1 Group" is a child of "Child1 Group".
See project structure example below: .

Sketch project structure example

0 Answers0