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

duplicate() bug?

Advocate ,
Sep 26, 2016 Sep 26, 2016

Hi. New in Photoshop scripting, but somewhat seasoned in AE scripting.

For instance, I have 2 documents.

docA has 5 layers (all of them are selected)

docB has only Background layer.

if I do:

docA.layers[0].duplicate(docB) -> duplicates all 5 selected layers from docA to docB

docA.layers[1].duplicate(docB) -> duplicates 1 layer;

docA.layers[2].duplicate(docB) -> duplicates 1 layer;

etc.

Why

docA.layers[0].duplicate(docB)

duplicates all layers, instead of first layer in the stack? Is this a bug or am I doing something wrong?

If none of layers are selected in docA:

docA.layers[0].duplicate(docB) -> doesn't do anything

docA.layers[1].duplicate(docB) -> duplicates 1 layer;

docA.layers[2].duplicate(docB) -> duplicates 1 layer;

What am I missing here?

TOPICS
Actions and scripting
1.0K
Translate
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

Advocate , Sep 26, 2016 Sep 26, 2016

I have the feeling that (a) duplicating all the layers is in fact a bug and (b) it might be related to the layers[0] weirdness I've experienced here: Targeting a layer when none is selected.

Davide

Translate
Adobe
Community Expert ,
Sep 26, 2016 Sep 26, 2016

Is the anything special about the top layer in docA? Is it a normal pixel layer with content? 

JJMack
Translate
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 ,
Sep 26, 2016 Sep 26, 2016

All of the layers are fully opaque. nothing special about them.

Translate
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 ,
Sep 26, 2016 Sep 26, 2016

I have the feeling that (a) duplicating all the layers is in fact a bug and (b) it might be related to the layers[0] weirdness I've experienced here: Targeting a layer when none is selected.

Davide

Translate
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 ,
Sep 26, 2016 Sep 26, 2016

Hi David.

Yes this definitely feels related to your post.

If duplicating layer[0] while some other layers are selected - then entire selection is duplicated.

If no layers are selected, then duplicating layer[0] does nothing.

Definitely a bug.

Thanks for confirmation.

Translate
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
Community Expert ,
Sep 26, 2016 Sep 26, 2016

Photoshop does have a Duplicate Layers. Where when you have multiple layer selected the Layers menu item Duplicate Layer... changes to Duplicate Layers...  It can also change to Duplicate Group... However if you select  multiple groups  it changes to Duplicate Layers...

docA.layers[0].duplicate(docB) may be doing duplicate layer because all layers are the currently targeted.

Have you tried it with any one layer targeted instead of nothing targeted.  The other day we had a thread where thing seems to  go amuck sometimes in a script when there is no current Photoshop target. However, when it happened to me my Script troughs an error so I through in a try catch where the catch  targets a layer and retry's. the main function. You had noe error noth happen and the continued to run.

JJMack
Translate
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 ,
Sep 26, 2016 Sep 26, 2016

This issue seems to be happening only with layer[0].

If 1st & 2nd layers selected: docA.layers[0].duplicate(docB) will duplicate both layers;

If 2nd & 3rd layers selected: docA.layers[0].duplicate(docB) will duplicate layer[0] as expected;

Duplicate-2.png

Translate
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
Community Expert ,
Sep 27, 2016 Sep 27, 2016

Photoshop has many issues and Adobe does not address all issues so you may need to work around some Adobe issues.

JJMack
Translate
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 ,
Sep 27, 2016 Sep 27, 2016
LATEST

Yes I am aware of that, thank you.

But in case someone else is having same issues - let him know that this is a known issue and he's not alone in this.

Translate
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