Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Script runs correctly when run manually, but it gives an error when run on Start Up

  • Script runs correctly when run manually, but it gives an error when run on Start Up

    Posted by Gregory Forster on March 13, 2019 at 4:05 am

    I have a script that runs correctly when I load the project and run it myself. However, when I run it on start up by putting it in the StartUp folder it gives me this error:

    “Unable to execute script at line 1. After Effects error: Unable to call “item” because of parameter 1. The range has no values”

    Thanks,
    Greg

    Dan Ebberts
    replied 7 years, 6 months ago
    2 Members · 5 Replies
  • 5 Replies
  • Dan Ebberts

    March 13, 2019 at 4:17 am

    It might help if we could see the script.

    Dan

  • Gregory Forster

    March 13, 2019 at 4:29 am

    Oh yeah, that makes sense…

    var compToBeOutput = app.project.item(35);
    var comp1 = app.project.item(1);
    var numGames = 7;
    var p = 3;

    compToBeOutput.duration = (90*numGames)/30;

    compToBeOutput.layers.add(comp1);

    for (i = 0; i<numGames-1; i++) {
    var newComp = comp1.duplicate();
    var newLayer = compToBeOutput.layers.add(newComp);
    newLayer.startTime = p;
    p = p + 3;
    }

  • Dan Ebberts

    March 13, 2019 at 5:30 am

    My guess is that even when you launch AE by double-clicking a project file, any startup scripts get run after the plugins load, but before the project does. So it won’t know what to make of app.project.item(35) because there won’t be any items yet.

    Dan

  • Gregory Forster

    March 13, 2019 at 5:39 am

    Yeah I think that’s the case. Thanks.

    I added a .sleep to the script to make it wait for 10 seconds and the project didn’t load until the scripts completed.

  • Dan Ebberts

    March 13, 2019 at 5:51 am

    I don’t know if this will work, but here’s what I’d try. Wrap your startup code in a function, make that function part of the app object, and schedule it to run as a task in 5 seconds, like this:


    function myInit(){
    var compToBeOutput = app.project.item(35);
    var comp1 = app.project.item(1);
    var numGames = 7;
    var p = 3;

    compToBeOutput.duration = (90*numGames)/30;

    compToBeOutput.layers.add(comp1);

    for (i = 0; i

    Dan

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