I've been googling all day to find a way to align a layer which is converted to Smart Object center to the canvas proceeded by scripting, but haven't found a solution so far. I ended up with the code below, but it doesn't do the job. Could anyone help, please?
var baseFile = new File(openDialog()); //open base JPEG file
var workFile = new File(openDialog()); //open work JPEG file
var baseDoc = app.open(baseFile);
var workDoc = app.open(workFile);
createSO(workDoc.layers[0]);
workDoc.resizeImage(280,280);
workDoc.artLayers[0].duplicate(baseDoc, ElementPlacement.INSIDE);
app.activeDocument = baseDoc;
var Hoffset = (baseDoc.width - workDoc.width) / 2;
var Voffset = (baseDoc.height - workDoc.height) / 2;
baseDoc.layers[1].position = Array(Hoffset, Voffset);
function createSO(){
var doc = app.activeDocument;
var idnewPlacedLayer = stringIDToTypeID( "newPlacedLayer" );
executeAction( idnewPlacedLayer, undefined, DialogModes.NO );
return doc.activeLayer;
}