Copy link to clipboard
Copied
Hi,
Within .js file i can fine the extension root using:
var csInterface = new CSInterface();
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION)
how do i get the extension path from within .jsx file?
I want to use:
var scriptDir =<path to extensionRoot>/host/libs
var scriptFile = "/myScript.jsx";
var runScript = File(scriptDir + scriptFile);
$.evalFile (runScript);
my jsx file is under extentionRoot/host
myScript is under extentionRoot/host/libs
Until recently my scriptDir was external but i want to move everything under the extension folder.
Copy link to clipboard
Copied
Did you look at my JSX.js A Game Changer in Adobe HTML Extensions Development? – Creative-Scripts.com ?
If you use that you can just use $.__dirname
You can look at the source code there of how that is done.
Copy link to clipboard
Copied
$.fileName gives you the path to the current JSX file, from there you can find the directory:
var filePath = $.fileName;
var fileDir = (new File(filePath)).path;
fileDir;
Copy link to clipboard
Copied
This is the 1st thing i tried but this yields the path to Photoshop installation, not the the extension root.
i need this definition which is in the js file
var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION)
but in my jsx file.
Copy link to clipboard
Copied
Just tested and
var filePath = $.fileName;
var fileDir = (new File(filePath)).path;
fileDir;
alert(fileDir)
Works for me in Photoshop 20.0.5, although it has to be run from a saved JSX file or from a function in a saved file, it won't work if you run it straight from csInterface.evalScript() without calling a function within a JSX file, cause otherwise it's an anonymous function and $.fileName make no sense in that case.
Copy link to clipboard
Copied
i placed, as you suggested, this in my main.jsx:
function getExtRoot(){
var filePath = $.fileName;
var fileDir = (new File(filePath)).path;
alert(fileDir);
return fileDir;
}
At the bottom i have my actual function whic should run my final script.
When set scriptDir to the full puth it is working, when i use it like this it returns the path to Photoshop installation
function createSplitWrapper(panelData) {
var scriptDir = getExtRoot();
var scriptFile = "/createSplitLayout.jsx";
var runScript = File(scriptDir + scriptFile);
alert("scriptDir:" + scriptDir + "\nrunScript" + runScript);
$.evalFile (runScript);
}
Copy link to clipboard
Copied
I gave up...
I simple passed the path as a variable from the js to the jsx.
Copy link to clipboard
Copied
Your example works fine on my machine. Maybe you have another panel or section of code modifying the $ object somewhere.
Also, there's nothing wrong with the js to jsx approach, that's how it's done in the sample.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more