Copy link to clipboard
Copied
Hey
I want to know if it is possible to place a Photoshop file inside another Photoshop file as a Linked Smart object.
I know that this is possible using the File -> Place Linked, but I want to be able to use the Adobe CEP scripting to perform this action.
Anyone who has worked on this before?
Copy link to clipboard
Copied
Do you mean ESTK Scripting?
// select files and place as smart objects;
// 2014, use it at your own risk;
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
// select files;
if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog ("please select files", '*.jpg;*.tif;*.pdf;*.psd;*.bmp', true)}
else {var theFiles = File.openDialog ("please select files", getFiles, true)};
if (theFiles.length > 0) {
for (var m = 0; m < theFiles.length; m++) {
var theLayer = placeScaleRotateFile(theFiles[m], 0, 0, 100, 100, 0, true);
var theFactor = myDocument.width / (theLayer.bounds[2] - theLayer.bounds[0]) * 100;
theLayer.resize (theFactor, theFactor, AnchorPosition.MIDDLECENTER)
}
}
};
////// get psds, tifs and jpgs from files //////
function getFiles (theFile) {
if (theFile.name.match(/\.(eps|ai|jpg|tif|psd|pdf|)$/i)) {
return true
};
};
////// place //////
function placeScaleRotateFile (file, xOffset, yOffset, theXScale, theYScale, theAngle, linked) {
// =======================================================
var idPlc = charIDToTypeID( "Plc " );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
desc5.putPath( idnull, new File( file ) );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc5.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc6 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( idHrzn, idPxl, xOffset );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( idVrtc, idPxl, yOffset );
var idOfst = charIDToTypeID( "Ofst" );
desc5.putObject( idOfst, idOfst, desc6 );
var idWdth = charIDToTypeID( "Wdth" );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idWdth, idPrc, theYScale );
var idHght = charIDToTypeID( "Hght" );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( idHght, idPrc, theXScale );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc5.putUnitDouble( idAngl, idAng,theAngle );
if (linked == true) {
var idLnkd = charIDToTypeID( "Lnkd" );
desc5.putBoolean( idLnkd, true );
};
executeAction( idPlc, desc5, DialogModes.NO );
// =======================================================
return app.activeDocument.activeLayer;
};