Someone helped me on another place, so found it!
Big thanks to Adam Plouff (founder of battleaxe.co, answered me on his Discord server).
In his words “The script doesn’t understand relative path notation. So you want to get the path of the script, go up a folder then to the ffx file”
Here’s the working code snippet:
// Apply the effects from the .ffx file to the map layer
var filePath = File(File($.fileName).parent.fullName + "/PXDMAP.ffx")
if (filePath.exists) {
mapLayer.applyPreset(filePath);
} else {
alert('PXDMAP.ffx is missing')
}
This also displays an error message if the file isn’t found.
If anyone faces this problem, just did research and to go back folders (ie. this script is in the ScriptUI Panels folder and I want to reference a script from the Presets folder, located two folders above), you do
./../../Presets/PXDMAP.ffx
Instead of
/PXDMAP.ffx
Hopefully this helps someone else too in the future!