Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Why this expression breaks with the new JavaScript?

  • Why this expression breaks with the new JavaScript?

    Posted by David Cabestany on October 27, 2020 at 7:47 pm

    This expression works fine with the legacy ExtendScript engine enabled but breaks with the newer JavaScript engine.

    I ran the update legacy expressions script and it fixed one line.

    Why is still returning an error?

    Note: I have redacted the last two folders in the path for privacy reasons.

    Thanks in advance.

    if ($.os.indexOf(“Mac”) != -1)

    {myPath = “/Volumes/Macintosh HD – Data/Users/david/Dropbox/xxxxxx/xxxxxxx/”

    };

    else

    {myPath = “file://c:\\\\Expressions\\”

    };

    myPath += “names.txt”;

    $.evalFile (myPath);

    eval(thisComp.name)[0];

    Dan Ebberts replied 3 years, 10 months ago 3 Members · 9 Replies
  • 9 Replies
  • Brendon Murphy

    October 27, 2020 at 8:00 pm

    $.evalFile() is not supported in the new Engine – use a different method. You could try the open(‘r’) method.

  • David Cabestany

    October 27, 2020 at 8:04 pm

    Thanks Brandon,

    A (very quick) search for the open(‘r’) method did not yield anything useful, I mostly got intro to After Effects tutorials and posts.

    Can you elaborate a little on this method? never heard of it before

  • Brendon Murphy

    October 27, 2020 at 8:24 pm

    Something like this:

    // [1] Create file object for the file you want to run.

    var nested_file = new File("nested_script.jsx");

    // [2] Open the file for reading.

    nested_file.open("r");

    // [3] Read the file and evaluate the results.

    eval(nested_file.read());

    // [4] Close the file. That's it!

    nested_file.close();

  • Dan Ebberts

    October 27, 2020 at 8:50 pm

    You’ll probably want to switch to importing a .csv file if you’re just auto updating text.

    Dan

  • David Cabestany

    October 27, 2020 at 10:57 pm

    I don’t get the advantage of using csv files, I still have to manually enter the arrays for each text (for example 4,1, etc).

    Using this expression once I’m done creating the first comp all I have to do is duplicate it in the project panel and all the info updates automatically.

    I’m sure csv data is valuable but I have yet to find a project where I’d benefit from it.

  • David Cabestany

    October 27, 2020 at 10:59 pm

    Now here’s an idea:

    Is it possible to have the renders take their name from the comment in the project panel instead of the name of the composition?

  • Dan Ebberts

    October 28, 2020 at 12:08 am

    As far as I know, expressions don’t have access to the comments. So what’s actually in your text file, and what do your comp names look like?

    Dan

  • David Cabestany

    October 28, 2020 at 12:41 am

    The comps are named Name1, Name2, etc.

    Each comp is a lower third with regular names, Mike Jones, Rob Smith, Cindy Anderson, etc.

    When I send to render I have to manually rename each output so I know which render belongs to what clip once I mount them on Premiere.

  • Dan Ebberts

    October 28, 2020 at 6:44 am

    With a csv file you could have your expression get the data index from the comp name, which would be pretty simple if your comps were named like “Comp 1”, “Comp 2”, etc.

    Then, assuming your imported data file (named data.csv for this example) looks like this:

    Names

    Mike Jones

    Rob Smith

    Cindy Anderson

    you get the appropriate name like this:

    idx = parseInt(thisComp.name.split(" ")[1],10) - 1;

    footage(data.csv").dataValue([0,idx]) // result = Rob Smith for Comp 2

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