Skip to content

Instantly share code, notes, and snippets.

@sonburn
Created February 7, 2018 22:27
Show Gist options
  • Save sonburn/5078d85e7e7591cf2bf066ec766a4236 to your computer and use it in GitHub Desktop.
Save sonburn/5078d85e7e7591cf2bf066ec766a4236 to your computer and use it in GitHub Desktop.
var textLayers = getAllLayersOfClass("MSTextLayer"),
textLayerLoop = textLayers.objectEnumerator(),
textLayer;
while (textLayer = textLayerLoop.nextObject()) {
log(textLayer.attributedStringValue());
}
function getAllLayersOfClass(className) {
var array = NSArray.array(),
pageLoop = MSDocument.currentDocument().pages().objectEnumerator(),
page;
while (page = pageLoop.nextObject()) {
var predicate = NSPredicate.predicateWithFormat("className == %@",className),
matches = page.children().filteredArrayUsingPredicate(predicate);
array = array.arrayByAddingObjectsFromArray(matches);
}
return array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment