Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions thisLayer.index For Specific Parameter

  • thisLayer.index For Specific Parameter

  • Mike LeBel

    September 11, 2020 at 8:24 pm

    I’m trying to so something fairly basic but am coming across a repeated issue. I’d like to refer scaling in another Comp, but not choose a specific layer name. Instead I’d like to use the same layer number where I’m calling it from. The error is the same each time “BAD ARGUMENT. LAYER INDEX OUT OF RANGE EXPRESSION DISABLED”

    ReadScale=comp(“MyComp”).layer(4).transform.scale[0] //**Works well

    ReadScale=comp(“MyComp”).layer(“RefLayer”).transform.scale[0] //**Works well

    ReadScale=comp(“MyComp”).layer(thisLayer.index).transform.scale[0] //**Does not work

    ReadScale=comp(“MyComp”).layer(x).transform.scale[0] //**Does not work (where “x=5”)

    It seems as though no variable can be inserted into this location. I am able to use the following in another expression for a different parameter. But when I put it all together it still does not work.

    parseInt((thisLayer.index)-2 //**Works correctly

    Any feedback or food for thought would be greatly appreciated!


  • Brendon Murphy

    September 11, 2020 at 9:17 pm

    If I understand correctly – you are trying to use layer 5 in another comp to drive the scale of layer 5 in the current comp? See if this does it:

    layerNum = thisLayer.index

    refLayerScale = comp(“Comp 2”).layer(layerNum).transform.scale;

    [refLayerScale [0],refLayerScale [1]];

  • Mike LeBel

    September 11, 2020 at 9:52 pm

    Thank you so much for the quick reply! Sorry I add this question to the wrong message board.

    I agree that should work but I’m still receiving an error. “Bad Argument: layer index out of range Expression disabled.” I’m glad you’re thinking it should work too, but AE is just telling me no. Is there any reason why this would not work? Neither the one I’ve typed below or written before (using the variable “layerNum”).

    refLayerScale = comp(“Comp 2”).layer(thisLayer.index).transform.scale;

    The code above does not work, however, changing thisLayer.index to a numeric value does work. So I’m thinking the rest of my equation is good? Feel like I’m missing something else. Any thoughts?

  • Mike LeBel

    September 11, 2020 at 10:01 pm

    Oh man… I just found the issue. It was pointing to a comp that didn’t have enough layers so it was trying to ref a layer that didn’t exist. Thank you so much!

  • Brendon Murphy

    September 12, 2020 at 1:07 am

    Glad to help!

Viewing 1 - 5 of 5 posts

Log in to reply.

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