• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Copy 5 layers (or a layer set) to another opened document

Advocate ,
May 08, 2013 May 08, 2013

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.

TOPICS
Actions and scripting

Views

753

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Guru , May 08, 2013 May 08, 2013

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.

Votes

Translate

Translate
Adobe
Guru ,
May 08, 2013 May 08, 2013

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 08, 2013 May 08, 2013

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 );

};

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 08, 2013 May 08, 2013

Copy link to clipboard

Copied

Yeah Paul but you posted code.

By the way Gustavo , duplicate() also works on layerSets.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
May 09, 2013 May 09, 2013

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines