Copy to Destination

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Ronan
Posts: 2
Joined: Mon Dec 12, 2016 12:55 pm

Copy to Destination

Post by Ronan »

Hello All,
I am beginner in java script

I was wondering if it's possible to create a script that copy current layer to selected group or layer (near)
script should work like copy/paste ( for example i assign shortcut ctrl+alt+c for copy and ctrl+alt+v for paste)

Ps usually make copy (Layer via Copy) of layer above of current selected layer, its be nice if Ps make copy of layer to selected destination

here is good one ( Mike Hale version, thanks to Mike)
Send to group
https://www.ps-scripts.com/viewtopic.ph ... yer#p43128
Script its good when document have up to 100 layers, but
for documents who has more than hundred of layers (in some case more than 1000+)
is very irritate to scroll down/up through list(its too big ) every time


I need faster way,

1 Select the layer that I need to copy and press ctrl+alt+c

2. When i select in Layer Panel destination group or layer with Mouse(if is possible, i think should be faster with Mouse)
or
if i select on Canvas other layer(Auto-Select layer in the Move tool) which is situated in the destination

3. I press Ctrl+Alt+V script should copy layer


Sorry for my English.
Thanks!
influencebydesign
Posts: 9
Joined: Wed Nov 30, 2016 3:55 am

Re: Copy to Destination

Post by influencebydesign »

Ronan
Posts: 2
Joined: Mon Dec 12, 2016 12:55 pm

Re: Copy to Destination

Post by Ronan »

Thanks for link
You are the author of this script?

Unfortunately Copio script doesn't work as I expected, he just make a copy of layer in top of layer panels
The script is made up of 2 scripts
Copio - Copy.jsxbin - memorize selected layer
Copio - Paste.jsxbin - "paste" layer to top of layers, but not in destination group

I think the author has done a good job in the first part - memorize selected layer
second script Copio - Paste.jsxbin should be modified

It's possible to do the same in one script :

Code: Select all


#target photoshop

// layer via copy;

var id14 = charIDToTypeID( "CpTL" );
executeAction( id14, undefined, DialogModes.NO );

// move layer to top
var doc=app.activeDocument;
var moveLayer = doc.activeLayer;
var targetLayer = doc.layers[0];//say topmost layer;
moveLayer.move(targetLayer,ElementPlacement.PLACEBEFORE);
doc.activeLayer=targetLayer;
//SelectionLayer;
var laySB=doc.activeLayer.bounds;
doc.selection.select([[laySB[0],laySB[1]],[laySB[2],laySB[1]],[laySB[2],laySB[3]],[laySB[0],laySB[3]]], SelectionType.REPLACE, 0, false);
doc.activeLayer=moveLayer;
align('AdCV');
align('AdCH');
doc.selection.deselect();

function align(method) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc.putReference( charIDToTypeID( "null" ), ref );
desc.putEnumerated( charIDToTypeID( "Usng" ), charIDToTypeID( "ADSt" ), charIDToTypeID( method ) );
try{
executeAction( charIDToTypeID( "Algn" ), desc, DialogModes.NO );
}catch(e){}
}

In my opinion this is a very important function that will be widely used, it would be better if it would be done
But I do not know how I could do that
The easy part is to make copy of layer,
Second part move or 'paste' to destination probably not so easy to do

Does anyone have any idea how to do?