Created
September 21, 2010 01:27
-
-
Save milligramme/588999 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
#target "Illustrator" | |
var doc = app.documents[0]; | |
var topG = getTopGroup(doc.groupItems); | |
alert("top level group:"+topG.length+ "\r" + | |
"PageItems:" + doc.pageItems.length + "\r" + | |
"PathItems:" + doc.pathItems.length + "\r" + | |
"CompoundPathItems:" + doc.compoundPathItems.length + "\r" + | |
"GroupItems:" + doc.groupItems.length + "\r" + | |
"Selection:" + doc.selection.length); | |
/** | |
* get top level group items | |
* @param {Array} group Array of GroupItem | |
* @returns {Array} tgr Array of top level GroupItem | |
*/ | |
function getTopGroup (group) { | |
var tgr=[]; | |
for (var i=0; i < group.length; i++) { | |
//parent is Layer | |
if(group[i].parent.typename == "Layer"){ | |
//group is formed with single path item | |
if(group[i].pathItems.length == 1){ | |
tgr.push(group[i]); | |
} | |
//group is formed with compound path item | |
if(group[i].compoundPathItems.length == 1){ | |
tgr.push(group[i]); | |
} | |
//group include any page items(textframe, pathitem) | |
else if(group[i].pageItems.length != 0){ | |
tgr.push(group[i]); | |
} | |
} | |
} | |
return tgr; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment