Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
var doc = context.document
var selectLayersOfType_inContainer = function(layerType, containerLayer) {
// Filter layers using NSPredicate
var scope = (typeof containerLayer !== 'undefined') ? [containerLayer children] : [[doc currentPage] children],
predicate = NSPredicate.predicateWithFormat("(className == %@)", layerType),
layers = [scope filteredArrayUsingPredicate:predicate];
// Deselect current selection
[[doc currentPage] deselectAllLayers]
// Loop through filtered layers and select them
var loop = [layers objectEnumerator], layer;
while (layer = [loop nextObject]) {
[layer select:true byExpandingSelection:true]
log([layers count] + " " + layerType + "s selected")
// Select all Artboards in current page
// Select all Text Layers in current page
// Types of layers that can be selected :
// MSLayerGroup
// MSShapeGroup
// MSShapePathLayer
// MSTextLayer
// MSArtboardGroup

This comment has been minimized.

Copy link

commented Jul 8, 2015



This comment has been minimized.

Copy link

commented Jul 9, 2015

Hi !
This seems great and USEFULL
Will you create a version compatible with Sketch Toolbox ?


This comment has been minimized.

Copy link
Owner Author

commented Jul 11, 2015

@rodnem I will as soon as I can find some time. Any other selection features that you think would make it more useful?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.