如何在.jsx文件中更改相对路径的绝对路径。 (Photoshop扩展脚本)?

问题描述 投票:0回答:1

开发Photoshop扩展程序时遇到问题。我已经生成了写在.jsx文件中的动作代码。我需要将绝对路径更改为相对路径,以便用户可以访问该文件,而不管扩展名安装在哪里。

。jsx文件:

function step7(enabled, withDialog) {
    if (enabled != undefined && !enabled)
      return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    desc1.putInteger(cTID('Idnt'), 4);
    desc1.putPath(cTID('null'), new File("~/AppData/Roaming/Adobe/CEP/extensions/Mockups_Extension/psd/texture.png"));
    desc1.putEnumerated(cTID('FTcs'), cTID('QCSt'), sTID("QCSAverage"));
    var desc2 = new ActionDescriptor();
    desc2.putUnitDouble(cTID('Hrzn'), cTID('#Pxl'), -1.13686837721616e-13);
    desc2.putUnitDouble(cTID('Vrtc'), cTID('#Pxl'), 0);
    desc1.putObject(cTID('Ofst'), cTID('Ofst'), desc2);
    desc1.putUnitDouble(cTID('Wdth'), cTID('#Prc'), 249.5);
    desc1.putUnitDouble(cTID('Hght'), cTID('#Prc'), 249.5);
    executeAction(cTID('Plc '), desc1, dialogMode);
  };

非常感谢您的帮助。

javascript adobe extendscript
1个回答
0
投票

您需要从CEP端传递扩展路径。

CEP:

var extensionRoot = csInterface.getSystemPath(SystemPath.EXTENSION) + "/jsx/";
csInterface.evalScript('myScript("' + extensionRoot + '")');

JSX:

function myScript(path) {
    alert(new File(path + "/psd/texture.png").exists);
} // end of myScript()
© www.soinside.com 2019 - 2024. All rights reserved.