Last active
August 29, 2015 14:26
-
-
Save keremciu/210542ccc6590ef22d1a to your computer and use it in GitHub Desktop.
Sketch App: Select Invisible Layers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function is_group(layer) { | |
return [layer isMemberOfClass:[MSLayerGroup class]] || [layer isMemberOfClass:[MSArtboardGroup class]] | |
} | |
function is_invisible_selectit(layer) { | |
if([layer isVisible] == false) { | |
[layer select:true byExpandingSelection:true] | |
} | |
} | |
function searchChilds(layers) { | |
for (var x=0; x < [layers count]; x++) { | |
var childLayer = layers.array()[x]; | |
if (is_group(childLayer)) { | |
searchChilds([childLayer layers]); | |
} | |
is_invisible_selectit(childLayer) | |
} | |
} | |
// select all document | |
var doc = context.document | |
// deselect all layers | |
[[doc currentPage] deselectAllLayers] | |
// get all layers in current page | |
var all_layers = [[doc currentPage] layers] | |
// for loop for every layer | |
for(var i=0; i < [all_layers count]; i++) { | |
// get each layer | |
var layer = all_layers.objectAtIndex(i) | |
// if is group search childs | |
if (is_group(layer)) { | |
searchChilds([layer layers]) | |
} | |
// if it is a invis layer, select it | |
is_invisible_selectit(layer) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment