How do I cut and paste a group to a new document via actions?
I wrote a script to cut and paste groups in the first layer of a document, into new documents to isolate each group. While it works great via ESTK, and running as a script menu item, it cuts the groups from the original document, but will not paste them into newly created documents when running this menu item through an action. Is there a way to get this to run properly?
origDoc = app.activeDocument;
length = origDoc.layers[0].groupItems.length;
for(i=length; i>0; i--){
origDoc.activate();
app.executeMenuCommand('deselectall');
origDoc.layers[0].groupItems[i-1].selected = true;
app.cut();
newDoc = app.documents.add();
newDoc.activate();
app.paste();
}
Skipping the loops, even trying to run it only on the first group in a layer will not work as an action:
origDoc = app.activeDocument;
origDoc.activate();
app.executeMenuCommand('deselectall');
origDoc.layers[0].groupItems[0].selected = true;
app.cut();
newDoc = app.documents.add();
app.paste();
The other odd behavior is that the original document still seems to have items within the group selected after running the script even if I try to deselect all. Running the script again, the new documents show up is empty.
