Duplicate grouped objects in a different document
Hi guys,
I am writing a script to copy parts of a document into another document. In document A, I have isolated each group of elements (about two dozen text and graphic frames in each case) onto separate layers. So I want the script to group all objects on a given layer and then duplicate them in document B, at a specific position.
So far, I have this :
var myLayer1 = app.documents.item(0).layers.item("Layer1");
var myObjects1 = myLayer1.pageItems.everyItem();
var myGroup1 = new Array;
myGroup1 = myObjects1;
app.activeWindow.activePage.groups.add(myGroup1);
myGroup1.duplicate([-120, 0]);
I just tested the script by trying to duplicate my group of objects in another part of the same document, but this doesn't preserve each object's coordinates inside the group, instead giving all the duplicated objects the same coordinates [-120, 0]. The result is all my objects piled up, aligned by their top left corner. I might be missing something obvious. How can I preserve my objects' relative positions?
Thanks a lot
Ma