Page 1 of 1

Copy to Destination

Posted: Mon Dec 12, 2016 1:56 pm
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!

Re: Copy to Destination

Posted: Thu Dec 15, 2016 6:53 pm
by influencebydesign

Re: Copy to Destination

Posted: Tue Feb 07, 2017 2:04 pm
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?