Skip to content

Commit 072be44

Browse files
committed
trim down
1 parent d27ac74 commit 072be44

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

Duplicate-to-All.js

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,42 +13,34 @@
1313
*/
1414

1515
if( app.documents.length > 0 ){
16-
duplicateToAll();
16+
duplicateToAll();
1717
}
1818
function duplicateToAll(){
19-
docs = app.documents;
20-
curDoc = app.activeDocument;
21-
groupLayerset();
22-
for(var i = 0; i < docs.length; i++){
23-
if(curDoc != docs[i]){
24-
try {
19+
docs = app.documents;
20+
curDoc = app.activeDocument;
21+
groupLayerset();
22+
for(var i = 0; i < docs.length; i++){
23+
if(curDoc != docs[i]){
2524
var curLayer;
26-
try { curLayer = docs[i].activeLayer; } catch(e) {};
25+
try { curLayer = docs[i].activeLayer; } catch(e) {}
26+
curDoc.activeLayer.duplicate(docs[i],ElementPlacement.PLACEATBEGINNING);
2727
app.activeDocument = docs[i];
2828
app.activeDocument.activeLayer.name = 'Duplicate To All Group';
29-
if(curLayer){docs[i].activeLayer.move(curLayer, ElementPlacement.PLACEBEFORE);
29+
if(curLayer){docs[i].activeLayer.move(curLayer, ElementPlacement.PLACEBEFORE);}
3030
ungroupLayerset();
31-
} catch(e) {
32-
alert('"Duplicate to All" has encountered an error. Please email the text below to cm@cameronmcefee.com \n' + 'Error with PS Script: Duplicate to All at [duplicateToAll()] \n\n' + e);
33-
}
34-
35-
}
36-
app.activeDocument = curDoc;
37-
}
38-
ungroupLayerset();
39-
alert('"Duplicate to All" complete');
31+
}
32+
app.activeDocument = curDoc;
33+
}
34+
ungroupLayerset();
35+
alert('"Duplicate to All" complete');
4036
}
4137
function ungroupLayerset(){
42-
var m_Dsc01 = new ActionDescriptor();
43-
var m_Ref01 = new ActionReference();
44-
m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
45-
m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
38+
var m_Dsc01 = new ActionDescriptor();
39+
var m_Ref01 = new ActionReference();
40+
m_Ref01.putEnumerated( cTID( "Lyr " ), cTID( "Ordn" ), cTID( "Trgt" ) );
41+
m_Dsc01.putReference( cTID( "null" ), m_Ref01 );
4642

47-
try {
48-
executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );
49-
} catch(e) {
50-
alert('"Duplicate to All" has encountered an error. Please email the text below to cm@cameronmcefee.com \n' + 'Error with PS Script: Duplicate to All at [ungroupLayerset()] \n\n' + e);
51-
}
43+
executeAction( sTID( "ungroupLayersEvent" ), m_Dsc01, DialogModes.NO );
5244
}
5345
function cTID(s){return charIDToTypeID(s)}
5446
function sTID(s){return stringIDToTypeID(s)}
@@ -60,9 +52,6 @@ function groupLayerset(){
6052
var ref = new ActionReference();
6153
ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
6254
desc.putReference( charIDToTypeID('From'), ref );
63-
try {
55+
6456
executeAction( charIDToTypeID('Mk '), desc, DialogModes.NO );
65-
} catch(e) {
66-
alert('"Duplicate to All" has encountered an error. Please email the text below to cm@cameronmcefee.com \n' + 'Error with PS Script: Duplicate to All at [groupLayerset()] \n\n' + e);
67-
}
6857
};

0 commit comments

Comments
 (0)