Ok here is a bit of code to be going on with.
This first bit of code assumes you have the document open where you want the layerset "Group 1"
You could hard code the filename, but this examples lets you pick the file.
It opens the PSD selects layerset "Group 1" and duplicates it into your original document then closes the PSD, leaving your original document open...
Code:
main();
function main(){
if(!documents.length) return; //no documents open
var originalDoc = activeDocument;
var origName = decodeURI(activeDocument.name);
var newFile = null;
//select psd file
while(newFile == null){ newFile =File.openDialog("Please select PSD.","PSD File:*.psd");}
open(newFile);
try{
activeDocument.activeLayer = activeDocument.layerSets.getByName("Group 1");
}catch(e){
alert("Group 1 does not exist in this psd");
}
dupLayers(origName);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
function dupLayers(aDoc) {
function cTID(s) { return app.charIDToTypeID(s); };
var desc153 = new ActionDescriptor();
var ref61 = new ActionReference();
ref61.putEnumerated( cTID('Lyr '), cTID('Ordn'), cTID('Trgt') );
desc153.putReference( cTID('null'), ref61 );
var ref62 = new ActionReference();
ref62.putName( cTID('Dcmn'), aDoc );
desc153.putReference( cTID('T '), ref62 );
desc153.putInteger( cTID('Vrsn'), 2 );
executeAction( cTID('Dplc'), desc153, DialogModes.NO );
};
This example is generic again you can hard code your file but this code lets you select the required psd and "Place the selected document" into your open document.
(Same as File - Place).
This is handy for Watermarks etc...
Code:
main();
function main(){
if(!documents.length) return; //no documents open
var newFile = null;
//select psd file
while(newFile == null){ newFile =File.openDialog("Please select PSD.","PSD File:*.psd");}
//place psd file
placeFile(newFile);
}
function placeFile( file) {
var desc = new ActionDescriptor();
desc.putPath( charIDToTypeID('null'), file );
desc.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
var offsetDesc = new ActionDescriptor();
offsetDesc.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 );
offsetDesc.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 );
desc.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), offsetDesc );
executeAction( charIDToTypeID('Plc '), desc, DialogModes.NO );
};
Please let me know if you have any questions.