-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathDuplicate-to-All.js
More file actions
43 lines (41 loc) · 1.52 KB
/
Duplicate-to-All.js
File metadata and controls
43 lines (41 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if( app.documents.length > 0 ){
duplicateToAll();
}
function duplicateToAll(){
docs = app.documents;
curDoc = app.activeDocument;
groupLayerset();
for(var i = 0; i < docs.length; i++){
if(curDoc != docs[i]){
var curLayer;
try { curLayer = docs[i].activeLayer; } catch(e) {}
curDoc.activeLayer.duplicate(docs[i],ElementPlacement.PLACEATBEGINNING);
app.activeDocument = docs[i];
app.activeDocument.activeLayer.name = 'Duplicate To All Group';
if(curLayer){docs[i].activeLayer.move(curLayer, ElementPlacement.PLACEBEFORE);}
ungroupLayerset();
}
app.activeDocument = curDoc;
}
ungroupLayerset();
alert('"Duplicate to All" complete');
}
function ungroupLayerset(){
var m_Dsc01 = new ActionDescriptor();
var m_Ref01 = new ActionReference();
m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );
}
function cTID(s){return charIDToTypeID(s)}
function sTID(s){return stringIDToTypeID(s)}
function groupLayerset(){
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putClass( stringIDToTypeID('layerSection') );
desc.putReference( charIDToTypeID('null'), ref );
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
desc.putReference( charIDToTypeID('From'), ref );
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
};