JSX: Is there a way to get app.opendialog full path?
Hi guys. Is there a way to get the full path of a selected image via the open dialog or using any other method? I'd like to save the path in the extension so that it can be set to the path of the textures folder. The path always opens in the last path used in photoshop at this moment. Basically, I just want to capture the file path that is selected in the extension and set it temporarily until I reset it in the extension function.
Here's what I got:
fyi: getafilepathtoJS("getfilepath",selectedfile); ---- is an add listener in the main.js that captures the path but it only shows the filename.
function step1(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
var desc1 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Back'));
desc1.putReference(cTID('null'), ref1);
desc1.putBoolean(cTID('MkVs'), false);
var list1 = new ActionList();
list1.putInteger(1);
desc1.putList(cTID('LyrI'), list1);
executeAction(cTID('slct'), desc1, dialogMode);
};
// Select
function step2(enabled, withDialog) {
if (enabled != undefined && !enabled)
return;
var idPlc = charIDToTypeID( "Plc " );
var desc11 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var selectedFile = app.openDialog();
//return file path
getafilepathtoJS("getfilepath",selectedfile);
desc11.putPath( idnull, new File(selectedFile) );
var idFTcs = charIDToTypeID( "FTcs" );
var idQCSt = charIDToTypeID( "QCSt" );
var idQcsa = charIDToTypeID( "Qcsa" );
desc11.putEnumerated( idFTcs, idQCSt, idQcsa );
var idOfst = charIDToTypeID( "Ofst" );
var desc12 = new ActionDescriptor();
var idHrzn = charIDToTypeID( "Hrzn" );
var idPxl = charIDToTypeID( "#Pxl" );
desc12.putUnitDouble( idHrzn, idPxl, 0.000000 );
var idVrtc = charIDToTypeID( "Vrtc" );
var idPxl = charIDToTypeID( "#Pxl" );
desc12.putUnitDouble( idVrtc, idPxl, 0.000000 );
var idOfst = charIDToTypeID( "Ofst" );
desc11.putObject( idOfst, idOfst, desc12 );
executeAction( idPlc, desc11, DialogModes.NO );
};
step1();
step2();
};
