Created
February 7, 2018 22:27
-
-
Save sonburn/5078d85e7e7591cf2bf066ec766a4236 to your computer and use it in GitHub Desktop.
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
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