Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects How can I change the thisComp.layer(“layername”) by script ?

  • How can I change the thisComp.layer(“layername”) by script ?

    Posted by Supak Suksawat on March 5, 2022 at 4:46 pm

    Now, I get the script like this and I want change the “layername” in thisComp.layer

    original

    ———————————–

    FACE[i].transform.position.expression = ‘b=thisComp.layer(“layername”).transform.scale;\

    if(b>[0,100]){ \

    value=value-((b-[100,100])/10) \

    } \

    ———————————–

    but I want to change like this

    ———————————–

    FACE[i].transform.position.expression = ‘b=thisComp.layer(BEYER.name).transform.scale;\

    if(b>[0,100]){ \

    value=value-((b-[100,100])/10) \

    } \

    ———————————–

    but it didn’t work

    I want to change the “layername” to object.name

    How can I do that ?

    thank you

    Supak Suksawat replied 4 years, 2 months ago 3 Members · 4 Replies
  • 4 Replies
  • Frederic Berria

    March 6, 2022 at 11:40 pm

    You can give a try with the layer.index.

    thisComp.layer(1).transform.scale;

    I guess you defined :

    layer.name=« toto »;

    So use thisComp.layer(« toto »).property(« ADBE transform » ).property(«ADBE Scale »).setValue(1).

    (I think it’s better to use the proper names in case you share your script to a non-English person.)

    Anyway, reading your post, I just want to have a precision : do you try to catch layers inside a precomp ?

     

    Cheers,

     

     

  • Supak Suksawat

    March 7, 2022 at 12:43 pm

    I had the variable BEYER for catch the layer that name “BLACK EYE R” and I want it show in expression by script Umm.. I didn’t want to write like this

    FACE[i].transform.position.expression = ‘b=thisComp.layer(” BLACE EYE R”).transform.scale’

    because I have the variable BEYER that collect this layer that make me want to write

    FACE[i].transform.position.expression = ‘b=thisComp.layer(BEYER.name).transform.scale’

    how can I do like this ?

    thank you.

  • Walter Soyka

    March 8, 2022 at 4:59 pm

    I assume you’re trying using a script to write an expression into a property?

    Two things I see in this code snippet:

    1. It looks like you’re trying to reference a variable inside a string, and expecting it to evaluate; it will not. You need to separate out the string’s pieces and the variable, and concatenate them.

    2. You’re assigning that result to a variable that you’re not actually using or explicitly returning. This will work in this case, but in some cases it can result in an expression error.

    If you have this:

    FACE[i].transform.position.expression = 'b=thisComp.layer(BEYER.name).transform.scale';

    You probably want this instead:

    FACE[i].transform.position.expression = 'thisComp.layer("' +  BEYER.name + '").transform.scale';
  • Supak Suksawat

    March 8, 2022 at 5:11 pm

    Oh, yes this is some thing that I want

    thank you so much

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