This is hard-coded to search only for the group names you've given. It could be changed to be more dynamic: function countGroups() {
var aDoc = app.activeDocument;
var myLayer = prompt('Set Layer', 'VEI');
var ii = 0;
for (i = 0; i < aDoc.layers[myLayer].groupItems.length; i++) {
var myGroup = aDoc.layers[myLayer].groupItems[i];
if (myGroup.name == 'PEH' || myGroup.name == 'PEV') {
ii = ii + 1;
}
}
alert(ii);
}
countGroups(); EDIT: This version allows you to set the "Group" names within the script: function countGroups() {
var aDoc = app.activeDocument;
var myLayer = prompt('Set Layer', 'VEI'),
myGroup1 = prompt('Set Group1', 'PEH'),
myGroup2 = prompt('Set Group1', 'PEV');
var ii = 0;
for (i = 0; i < aDoc.layers[myLayer].groupItems.length; i++) {
var myGroup = aDoc.layers[myLayer].groupItems[i];
if (myGroup.name == myGroup1 || myGroup.name == myGroup2) {
ii = ii + 1;
}
}
alert(ii);
}
countGroups();
... View more