JS CS3 Fastest way to create a group
I have a selection of about 1050 elements and to create a group I'm using:
var myNewGroup = new Array;
for (i=app.selection.length-1; i>=0; i--) {
myNewGroup.push (app.selection);
}
var myGroup = app.activeDocument.groups.add(myNewGroup);
This works but it's very slow. I have tried the following:
var myNewGroup = app.selection;
var myGroup = app.activeDocument.groups.add(myNewGroup);
The app.selection approach gives me an Invalid parameter error. What I don't understand is that the working code creates an array and adds each element to the array then a group is created from that array.
With the second approach app.selection is an array so why does this group?