Copy link to clipboard
Copied
Hi
I have 2 opened documents. The first has 5 layers. I need these 5 layers to the second opened document. And this is my problem. The 5 layers creates a composition. So if I copy one by one, the position related to others layers will change.
In my script tried linking the layers before copying. No sucess. Tried to create a layerSet, but did not find any method to copy this layer set to second document 😕
Any idea how to copy the 5 layers to other document???
Thank you very much
Gustavo.
Are you using copy/paste or layer.duplicate? Duplicate will maintain all the layer data including position. If the documents are the same size and res, the dupped layer will be in the same place they were in the original document.
If you copy/paste you need to get the layer bounds in the origianl document then use layer.translate to move them in the correct position after the paste.
Copy link to clipboard
Copied
Are you using copy/paste or layer.duplicate? Duplicate will maintain all the layer data including position. If the documents are the same size and res, the dupped layer will be in the same place they were in the original document.
If you copy/paste you need to get the layer bounds in the origianl document then use layer.translate to move them in the correct position after the paste.
Copy link to clipboard
Copied
Mike beat me to it, I was thinking of duplicating the layers to the other document...
activeDocument = app.documents[0];
selectAllLayers();
dupLayers(app.documents[1].name)
function selectAllLayers() {
var desc29 = new ActionDescriptor();
var ref23 = new ActionReference();
ref23.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc29.putReference( charIDToTypeID('null'), ref23 );
executeAction( stringIDToTypeID('selectAllLayers'), desc29, DialogModes.NO );
}
function dupLayers(NewDocName){
var desc15 = new ActionDescriptor();
var ref9 = new ActionReference();
ref9.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc15.putReference( charIDToTypeID('null'), ref9 );
var ref10 = new ActionReference();
ref10.putName( charIDToTypeID('Dcmn'), NewDocName);
desc15.putReference( charIDToTypeID('T '), ref10 );
desc15.putInteger( charIDToTypeID('Vrsn'), 5 );
executeAction( charIDToTypeID('Dplc'), desc15, DialogModes.NO );
};
Copy link to clipboard
Copied
Yeah Paul but you posted code.
By the way Gustavo , duplicate() also works on layerSets.
Copy link to clipboard
Copied
Hi Michael and Paul
duplicate() worked perfectlly.
I just passed the duplicate(doc) without Element Placement value and it worked haha.
Thank you very much.
Best Regards