Stack in Bridge

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

jsgerin

Stack in Bridge

Post by jsgerin »

is to adapt this script, instead of grabbing the file selected, it capture the stack ...


Place smart object into pre-existing Photoshop file
script - Paul Riggott

Code: Select all#target Photoshop
main();
function main(){
if(!documents.length) return;
var fileList =[];
fileList =GetFilesFromBridge();
for(var a in fileList){
    placeFile(fileList[a]);
    }
}
function GetFilesFromBridge() {
function script(){
var fL = app.document.selections;
var tF=[];
for(var a in fL){
    if(fL[a].type =='file'){
        tF.push(new File(encodeURI(fL[a].spec.fsName)));
        }
    }
return tF.toSource();
}
 var fileList;
  var bt = new BridgeTalk();
  bt.target = "bridge";
        bt.body = "var ftn = " + script.toSource() + "; ftn();";
  bt.onResult = function( inBT ) { fileList = eval( inBT.body ); }
  bt.onError = function( inBT ) { fileList = new Array(); }
  bt.send(8); //timeout value in seconds
  bt.pump();
 if ( undefined == fileList ) fileList = new Array();
 return fileList;
}
function placeFile(filePath) {
    var desc18 = new ActionDescriptor();
    desc18.putPath( charIDToTypeID('null'), new File( filePath) );
    desc18.putEnumerated( charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa') );
        var desc19 = new ActionDescriptor();
        desc19.putUnitDouble( charIDToTypeID('Hrzn'), charIDToTypeID('#Pxl'), 0.000000 );
        desc19.putUnitDouble( charIDToTypeID('Vrtc'), charIDToTypeID('#Pxl'), 0.000000 );
    desc18.putObject( charIDToTypeID('Ofst'), charIDToTypeID('Ofst'), desc19 );
    executeAction( charIDToTypeID('Plc '), desc18, DialogModes.NO );
}