Copy link to clipboard
Copied
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?
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
Copy link to clipboard
Copied
Is the anything special about the top layer in docA? Is it a normal pixel layer with content?
Copy link to clipboard
Copied
All of the layers are fully opaque. nothing special about them.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
Photoshop has many issues and Adobe does not address all issues so you may need to work around some Adobe issues.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now