I found a JavaScript that will make every layer in Photoshop a smart object, which is awesome, but I am wondering if anyone can tweak it for me. I use this injunction with AppleScript. Due to not know much about Javascript I was hoping some kind person can tweak this to select all layers and make one smart object out of all layers in the current file.
The code I am using:
// MAIN
var doc = app.activeDocument;
var layers = doc.layers; //array of parent layer/layersets present in active document
for(var i = 0; i < layers.length; i++)
{
if(!layers[i].isBackgroundLayer) createSmartObject(layers[i]);
}
//FUNCTIONS
// create smartobject from specified layer (default is active layer)
function createSmartObject(layer)
{
var doc = app.activeDocument;
var layer = layer != undefined ? layer : doc.activeLayer;
if(doc.activeLayer != layer) doc.activeLayer = layer;
try
{
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );
return doc.activeLayer;
}
catch(e)
{
return undefined;
}
}// JavaScript Document
Update — Clarification
The above script takes each layer and one layer a time changes it to a smart object. I want it to select every layer in the document and make it into one smart object without flattening it.
So if I were to do it by hand for an example. I would make a PS doc with as many layers as I want. For argument sake lets say there is 3 layers. I would select the 3 layers(which is all the layer in the doc) and right click and select make smart object. Now I have one smart object with ever layer inside it.