Last active
October 1, 2022 18:56
-
-
Save KennyRedman/b8582079dabc1be17b05 to your computer and use it in GitHub Desktop.
Adobe Illustrator script that reorders all visible layers alphabetically
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
#target illustrator | |
main(); | |
function main(){ | |
if(!documents.length) return; | |
var doc = app.activeDocument; | |
var allLayers = app.activeDocument.layers; | |
var visibleLayers = []; | |
for(a=0; a<allLayers.length; a++){ | |
var ilayer = allLayers[a]; | |
if (ilayer.visible) { | |
visibleLayers.push(ilayer); | |
} | |
}; | |
var alphabetizedLayers = visibleLayers.sort( function(a,b) { return a > b } ); | |
sort_layers(doc, alphabetizedLayers); | |
} | |
function sort_layers(obj, abcLayers) { | |
for (var ri=0; ri<abcLayers.length;ri++) { | |
abcLayers[ri].zOrder(ZOrderMethod.SENDTOBACK); | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It’s been a while since I wrote that and I don’t have access to Illustrator anymore to test it out unfortunately. Sorry.