Created
June 22, 2011 08:45
-
-
Save milligramme/1039713 to your computer and use it in GitHub Desktop.
for Illustrator Sorting Layers
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" | |
/** | |
* sort layers (with sublayer) | |
*/ | |
var doc = app.documents[0]; | |
var lay = doc.layers; | |
var array_primary = []; | |
for (var i=0, iL=lay.length; i < iL ; i++) { | |
if (lay[i].layers.length === 0) { | |
array_primary.push( lay[i].name ); | |
} | |
else { | |
array_primary.push( lay[i].name ); | |
var array_secondary = []; | |
for (var j=0, jL=lay[i].layers.length; j < jL ; j++) { | |
array_secondary.push(lay[i].layers[j].name); | |
}; | |
var result2 = array_secondary.sort( function (a,b) { return a > b }); | |
// sort sublayers | |
sort_layer (lay[i], result2); | |
} | |
}; | |
var result1 = array_primary.sort( function(a,b) { return a > b } ); | |
// sort layers | |
sort_layer (doc, result1); | |
function sort_layer (obj, array) { | |
for (var ri=0, riL=array.length; ri < riL ; ri++) { | |
obj.layers.getByName(array[ri]).zOrder( ZOrderMethod.SENDTOBACK ); | |
}; | |
} |
Hey Milligramme,
I've found a way to sort the pathItems within Adobe Illustrator:
МАМКУ ТВОЮ ЕБАЛ
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey Milligramme,
Thank you for making this script, it's a step in a great direction. One question though: Is there any way for this script to sort the bottom most layer, or the layer with the object on it?
Basically what I'm trying to achieve is a layer group by state, then by provider, then by city, then the dot representing the city.
Example:
-- Charter
--- Cable
---- Gillette, WY
---- Casper, WY
---- Albin, WY
That above script so far will sort everything except the final (deepest) layer, the one with the object (my dot). So my Cities are still unsorted alphabetically. I've tried moving them to the top level just in-case they were too "deep" in the layering, but that didn't make any difference.
Thanks