If anyone can point me in the right direction on how to move or copy a group of selected layers from the active Photoshop document to another open document, that would be fabulous
At this point, for me, it would only be these two documents open, so iterating through the Documents and finding the non-active one is the simple part. Also, I believe finding the currently selected layers isn't a big issue either.. I just have no idea how to copy the layers into the other document.
Thanks for any help!
Izz
Move/Copy Layers From Active Photoshop Doc to Another
-
Mike Hale
Move/Copy Layers From Active Photoshop Doc to Another
You can use layer.duplicate() to copy a layer from one document to another.
-
IsraelThompson
Move/Copy Layers From Active Photoshop Doc to Another
Documentation on proper usage of "ElementPlacement" PLACEAFTER and PLACEBEFORE seem scarce...
The only thing I see people using in all the threads I've been able to find here on the site or web look like ElementPlacement.PLACEAFTER or ElementPlacement.PLACEBEFORE with nothing attached to the end, etc. Normally, one would assume that before or after refers to an active/selected layer in the moveTo document, but this doesn't seem to be the case when I try it, as it always puts the item at the top of the layer hierarchy.
ATBEGINNING and ATEND work perfectly... But I'm uncertain how to tell it to insert directly before or after a specific artLayer (and it actually work).
Any insight?
Izz
The only thing I see people using in all the threads I've been able to find here on the site or web look like ElementPlacement.PLACEAFTER or ElementPlacement.PLACEBEFORE with nothing attached to the end, etc. Normally, one would assume that before or after refers to an active/selected layer in the moveTo document, but this doesn't seem to be the case when I try it, as it always puts the item at the top of the layer hierarchy.
ATBEGINNING and ATEND work perfectly... But I'm uncertain how to tell it to insert directly before or after a specific artLayer (and it actually work).
Any insight?
Izz
-
IsraelThompson
Move/Copy Layers From Active Photoshop Doc to Another
Oh.. and this is an example of my test code:
Code: Select allvar docRef = app.activeDocument
var moveGroup = docRef.layerSets.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var beforeLayer = moveTo.artLayers.getByName('Layer 5')
var layerRef = moveGroup.duplicate(moveTo, ElementPlacement.PLACEBEFORE.beforeLayer)
Code: Select allvar docRef = app.activeDocument
var moveGroup = docRef.layerSets.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var beforeLayer = moveTo.artLayers.getByName('Layer 5')
var layerRef = moveGroup.duplicate(moveTo, ElementPlacement.PLACEBEFORE.beforeLayer)
-
Mike Hale
Move/Copy Layers From Active Photoshop Doc to Another
When you dupe a layer to a different doc you can only use ElementPlacement.PLACEATBEGINNING( default ) or ElementPlacement.PLACEATEND. If you want the layer in a different placement you need to move the layer after the dupe step.
-
IsraelThompson
Move/Copy Layers From Active Photoshop Doc to Another
Much thanks for clarifying that!
-
blendingshadow
Move/Copy Layers From Active Photoshop Doc to Another
sorry new to scripting and found this thread.
Not sure, what are you putting in 'POOP', Untitled-1, and Layer 5?
I am assuming this need to be swapped out for something?
I am also trying to move a group of layers from one document to another.
Not sure, what are you putting in 'POOP', Untitled-1, and Layer 5?
I am assuming this need to be swapped out for something?
I am also trying to move a group of layers from one document to another.
-
IsraelThompson
Move/Copy Layers From Active Photoshop Doc to Another
Hi blendingshadow,
Here's an update:
Code: Select allvar docRef = app.activeDocument
var moveGroup = docRef.layerSets.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var layerRef = moveGroup.duplicate(moveTo, ElementPlacement.PLACEATBEGINNING)
In the example code above, "POOP" would be the name of a "group" or set of layers that i'm trying to move from the active document. "Untitled-1" is the name of the other open document in Photoshop that I'm trying to move the group to.
If you simply wanted to move an individual layer, you would use docRef.artLayers.getByName('layer name') instead, like so:
Code: Select allvar docRef = app.activeDocument
var moveLayer = docRef.artLayers.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var layerRef = moveLayer.duplicate(moveTo, ElementPlacement.PLACEATBEGINNING)
What Mike was clarifying above was the "PLACEATBEGINNING" and "PLACEATEND" were the only options available when moving from one document to another. PLACEATBEGINNING places the layer or group at the top of your layer pallete, whereas PLACEATEND would put it at the bottom (just above your Background layer, if it's still locked).
Hope this helps!
Izz
Here's an update:
Code: Select allvar docRef = app.activeDocument
var moveGroup = docRef.layerSets.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var layerRef = moveGroup.duplicate(moveTo, ElementPlacement.PLACEATBEGINNING)
In the example code above, "POOP" would be the name of a "group" or set of layers that i'm trying to move from the active document. "Untitled-1" is the name of the other open document in Photoshop that I'm trying to move the group to.
If you simply wanted to move an individual layer, you would use docRef.artLayers.getByName('layer name') instead, like so:
Code: Select allvar docRef = app.activeDocument
var moveLayer = docRef.artLayers.getByName('POOP')
var moveTo = app.documents.getByName('Untitled-1')
var layerRef = moveLayer.duplicate(moveTo, ElementPlacement.PLACEATBEGINNING)
What Mike was clarifying above was the "PLACEATBEGINNING" and "PLACEATEND" were the only options available when moving from one document to another. PLACEATBEGINNING places the layer or group at the top of your layer pallete, whereas PLACEATEND would put it at the bottom (just above your Background layer, if it's still locked).
Hope this helps!
Izz
-
blendingshadow
Move/Copy Layers From Active Photoshop Doc to Another
Yeah was having issues with the Untitled-1 part / replacing it with another document.
Found it just as easy to create a new document and merge the two seperate elements in the Untitled-1
Thank you for your help
Found it just as easy to create a new document and merge the two seperate elements in the Untitled-1
Thank you for your help
-
Baos
Move/Copy Layers From Active Photoshop Doc to Another
Thanks a bunch Israel!
I've been struggling with the handling of layers and groups for a while. Your example had all the answers I was looking for.
I've been struggling with the handling of layers and groups for a while. Your example had all the answers I was looking for.