Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Stop code running, until precomp isn’t ready

  • Stop code running, until precomp isn’t ready

    Posted by Gerg Tolcs on September 22, 2015 at 11:25 am

    Hi, my problem is this: I’m writing a script. in a for cycle, it generates 6 layers, pre-comp them, generate 6 (similar) layers, pre-comp them, etc, everything is ok. But, I want 2 layers (not all the 6) to pre-comp, before pre-comp the 6 layers, and want to do some stuff with layers, and the pre-comped 2 before the ‘bigger’ pre-comping. The problem is – as I see – that the pre-comping of the 2 is not ready, when the script want to use it, so I need something, a trick or whatever, what stops the code of the for cycle, when the AE is working on pre-comping.

    I tried to make a recursive function, with the new (2 layers pre-comp) name but it isn’t work – I know it’s ugly, but…

    I write it down, in the code section, I don’t want to write the full code, it was perfect, before the 2 layers precomp stuff. Google didn’t help me, thank you the answers!

    var testPrecomp = function(){
    if(typeof(mainComp.layers.byName('preCompTwo')) === 'object'){
    //Do the job
    }else{
    testPrecomp();
    }
    };

    Gerg Tolcs replied 10 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Xavier Gomez

    September 22, 2015 at 3:29 pm

    It’s not very clear what you are trying to do and where the problem comes from.

    I think that, in a script, an instruction is not executed before the previous one is not actually finished, including what it may represent inside After Effects (“precomping”, rendering, whatever). What error do you have ? Any chance that you refer to objects (layers) that dont exist anymore because of the precomp operation?

    Xavier.

  • Gerg Tolcs

    September 22, 2015 at 4:04 pm

    Thank you, and sorry, I was totally wrong.

    I did the pre-comp, but I made some silly (spelling) mistake, and the result was undefined later, when I wanted to work with that. I guess, the error handling of the browsers, and IDEs is too comfortable 🙂 I’m new in AE scripting, and sometimes I think, I don’t know something special and important, instead of reading again my code :/

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