Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by Sebastien Allain on July 17, 2007 at 1:29 pm

    I’m using such expression to read some value:
    target=comp(thisComp.layer(1).name).layer(thisComp.name);

    I need to automatically target nothing or something else when the target is not available for a moment (no existence)
    (in order not to have an error like this: “impossible to find…”)

    I don’t want to switch on/off each time all this expression.

    it may be something with if(…) has…

    Help please !

    sebastien

    Dan Ebberts replied 18 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 17, 2007 at 1:46 pm

    You can use JavaScript’s try/catch construct for this, like this:

    try{
    target=comp(thisComp.layer(1).name).layer(thisComp.name);
    }catch(err){
    target = // something else
    }

    In the catch section you have to define what value to use for target if the try section fails.

    Dan

  • Sebastien Allain

    July 17, 2007 at 3:37 pm

    Thanks Dan ! G

  • Sebastien Allain

    July 17, 2007 at 4:37 pm

    Now i need to read the reel scale of a parented layer.
    I don’t understand yet the difference between World and Comp but i remember Dan your expression:

    L = comp(“target”).layer(“target”);
    P = L.toComp(L.L.anchorPoint);

    so i’ve tried with no luck

    L = comp(“3×1”).layer(“LIGNES”);
    P = L.toComp(L.transform.scale);

    Can ask you one more time ?

    sebastien

  • Dan Ebberts

    July 17, 2007 at 5:11 pm

    Try this:

    L = comp(“3×1”).layer(“LIGNES”);

    if (L.hasParent){
    s1 = L.parent.transform.scale;
    s2 = L.transform.scale;
    [s1[0]*s2[0]/100, s1[1]*s2[1]/100]
    }else{
    L.transform.scale
    }

    Dan

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