-
1. Re: JS CS3 Fastest way to create a group
RorohikoKris-u5pUJw Oct 21, 2009 7:30 PM (in response to John.Kordas)Hmm... Try
var myNewGroup = app.selection.slice(0);
var myGroup = app.activeDocument.groups.add(myNewGroup);
AFAIK app.selection is a 'pseudo-array' - it tastes and smells like an array, but it ain't one. The .slice(0) trick is something I tend to use to force these to convert to a 'real' array.
Let us know whether it works!
Cheers,
Kris
-
2. Re: JS CS3 Fastest way to create a group
John.Kordas Oct 21, 2009 7:39 PM (in response to RorohikoKris-u5pUJw)Thanks Kris for the quick reply. Unfortunately I'm still getting an Invalid parameter on the
var myGroup = app.activeDocument.groups.add(myNewGroup);
Any other suggestions?
-
3. Re: JS CS3 Fastest way to create a group
RorohikoKris-u5pUJw Oct 21, 2009 8:23 PM (in response to John.Kordas)I had a quick check - your initial attempt with app.selection seems to work for me - no .slice(0) needed.
But one thing to be aware of: don't run the same script twice in quick succession. What happens is this:
a) you run the script -> all is well; selection becomes a group
b) you run the script again -> invalid parameter (because now your selection only has a single element in it - the group)
Could this be the issue you see? Re-select and make sure your selection is not already grouped before trying.
I'd change it so it becomes a variation of:
var myNewGroup = app.selection;
if (myNewGroup.length > 1)
{
var myGroup = app.activeDocument.groups.add(myNewGroup);
}
-
4. Re: JS CS3 Fastest way to create a group
John.Kordas Oct 21, 2009 8:56 PM (in response to RorohikoKris-u5pUJw)Thanks again Kris,
The document I'm trying this on is supplied not created by me so I should of run a test on a doc a created first, so I did. I made a new A4 doc and place a number of text elements on the page then selected them and ran the script again. Sure enough the selection became a group.
So I went back to the supplied doc and selected a couple of the frame and check under the Object menu , Content and to my surprise the options Graphic, Text, and Unassigned were all grayed out (could not select any).
Yet when I ran:
$.write(app.selection[1].constructor.name+"\n");
the console returns TextFrame and for
$.write(app.selection[1].contentType+"\n");
the console returns 1952412773 (TEXT_TYPE).
So there seems to be an issue with the file not the script. Thanks for you help Kris much appreciated.

