Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save monaye/1011d70090d5525eb08e07346d0f2761 to your computer and use it in GitHub Desktop.

Select an option

Save monaye/1011d70090d5525eb08e07346d0f2761 to your computer and use it in GitHub Desktop.
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
selectLayersOfType_inContainer("MSArtboardGroup")
// Select all Text Layers in current page
//selectLayersOfType_inContainer("MSTextLayer")
// Types of layers that can be selected :
// MSLayerGroup
// MSShapeGroup
// MSShapePathLayer
// MSTextLayer
// MSArtboardGroup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment