Created
February 10, 2011 22:34
-
-
Save itfrombit/821502 to your computer and use it in GitHub Desktop.
This file contains 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 path = "/Users/jsb/Desktop/LayerTest"; | |
var filename = "jefftest.acorn"; | |
var acorn = JSTalk.application("Acorn"); | |
var doc = acorn.open(path + "/" + filename); | |
var count = doc.layers().count(); | |
for (i = 0; i < count; i++) | |
{ | |
doc.layers()[i].visible = NO; | |
} | |
for (i = 0; i < count; i++) | |
{ | |
if (i > 0) | |
doc.layers()[i-1].visible = NO; | |
doc.layers()[i].visible = YES; | |
doc.dataOfType("public.png").writeToFile(path + "/layer" + i + ".png"); | |
} | |
doc.close(); |
No, that was just sloppy code. You don't actually have to duplicate the document at all. Here's an updated version that's a little cleaner.
ok!. wondered about that. thanks for the clarification.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there any reason to duplicate the document for each layer? seems the tmpDoc.duplicate() and tmpDoc.close could go outside the outer loop. I don't have time to try this at the moment but wondered... you set them visible/invisible each time through the loop... ?
I have a similar script that uses the names of the layers as the names of the output files which is handy for some cases.