Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Image path problem in After Effects script.

  • Image path problem in After Effects script.

    Posted by Joshua Faget on September 26, 2016 at 7:03 am

    Hello,

    I have the following problem. When I run my script from File>Scripts>MyScript it works, but when I open it from Windows>MyScript as a dockable panel it says that the image doesn’t exist.

    What I want is to tell After Effects to look in “[after effects folder]/Scripts/aCustomFolder/icon.png”

    What am I doing wrong?

    var myButton= mainGroup.add("iconbutton", undefined, image="./Scripts/(ImageAssets)/MyButton.png");

    Xavier Gomez replied 9 years, 7 months ago 4 Members · 4 Replies
  • 4 Replies
  • Miguel De mendoza

    September 26, 2016 at 8:25 am

    If you are running as a dockable panel, your script may be in Scripts/ScriptUI Panels. This notation “./” represents the current directory. If your “(ImageAssets)” folder is inside Scripts folder, you can access like this “../(ImageAssets)/MyButton.png”, wher “../” represents the parent folder of where the script is.

  • Joshua Faget

    September 26, 2016 at 9:27 am

    Hello,

    When I run my script from “ExtendScript” with this:
    var myButton= mainGroup.add(“iconbutton”, undefined, image=”./Scripts/(ImageAssets)/MyButton.png”);

    It works, but when I save my Script and place it in the Scripts folder AND in the ScriptUI Panels folder … it stops working.

    If I change it to
    var myButton= mainGroup.add(“iconbutton”, undefined, image=”./(ImageAssets)/MyButton.png”);
    it doesn’t work neither when I run it from the Scripts folder nor when I run it from ScriptUI Panels folder…

    What I am trying to achieve is to avoid “C:/Program Files…etc”

  • Jakob Wagner

    October 3, 2016 at 1:10 pm

    I do something like this, maybe it’s what your looking for:

    var scriptPath = File($.fileName).parent.fsName;
    var imagePath = scriptPath+”/myfolder/imagename.png”

    – Jakob

  • Xavier Gomez

    October 3, 2016 at 1:21 pm

    fsName is mostly for display i think.
    To make sure that your path will work on any system, absoluteURI is better:

    var scriptPath = File($.fileName).parent.absoluteURI;

    or (same result):
    var scriptPath = File($.fileName).path;

    then when appending the relative path, it’s better to escape the added string:

    var imagePath = scriptPath + encodeURI("/myfolder/imagename.png");

    Xavier

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy