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

Does .duplicate() copy element to a new document?

Engaged ,
Jun 13, 2017 Jun 13, 2017

Copy link to clipboard

Copied

I am looking at the 'Export Layers To Files.jsx' to convert the parts of the exportChildren to C++ for my plugin, I need to know does .duplicate() duplicate a Element to a new document (does it copy the element, create a new doc, and paste it)?

function exportChildren(dupObj, orgObj, exportInfo, dupDocRef, fileNamePrefix) {

    for( var i = 0; i < dupObj.artLayers.length; i++) {

        if (exportInfo.visibleOnly) { // visible layer only

            if (!orgObj.artLayers.visible) {

  continue;

  }

        }

        dupObj.artLayers.visible = true;

        var layerName = dupObj.artLayers.name;  // store layer name before change doc

        var duppedDocumentTmp = dupDocRef.duplicate();

        if ((psdIndex == exportInfo.fileType)||(png24Index == exportInfo.fileType)||(png8Index == exportInfo.fileType)) { // PSD: Keep transparency

            removeAllInvisible(duppedDocumentTmp);

TOPICS
Actions and scripting

Views

2.3K

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

Community Expert , Jun 14, 2017 Jun 14, 2017

Perhaps! In that script it would depend on what "dupDocRef" is.   There are many duplicate methods in  Adobe Photoshop's Scripting DOM.

Method    Paramaters                             Parameter type                     Returns           What it does

duplicate([relativeObject][, insertionLocation]) ArtLayer|LayerSet,ElementPlacement ArtLayer|LayerSet Creates a duplicate of the object .

duplicate([targetDocument])                      Document                           Channel           Duplicates t

...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 14, 2017 Jun 14, 2017

Copy link to clipboard

Copied

LATEST

Perhaps! In that script it would depend on what "dupDocRef" is.   There are many duplicate methods in  Adobe Photoshop's Scripting DOM.

Method    Paramaters                             Parameter type                     Returns           What it does

duplicate([relativeObject][, insertionLocation]) ArtLayer|LayerSet,ElementPlacement ArtLayer|LayerSet Creates a duplicate of the object .

duplicate([targetDocument])                      Document                           Channel           Duplicates the channel.

duplicate([name ][, mergeLayersOnly])            string,boolean                     Document          Creates a duplicate of the document object.

duplicate([relativeObject][, insertionLocation]) ArtLayer|LayerSet,ElementPlacement LayerSet          Creates a duplicate of the object.

duplicate(name)                                  string                                               Duplicates pathItem object with the new name.

Look like it is method 4 the way it is coded so yes it creates a new document in Photoshop and returns the document object in the variable  duppedDocumentTmp

It look line method 4 because of the variable name used by the coder implies a document object is expected to be returned.

Then all the invisible layer in the duplicated document are then removed by the script in this new document.

JJMack

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