Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions thisLayer.index For Parameter

  • thisLayer.index For Parameter

  • Mike LeBel

    September 11, 2020 at 9:23 pm

    I’m trying to do 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!

    -Thanks!

  • Andrei Popa

    September 12, 2020 at 10:09 am

    I tried to link my layer size to another size from another comp like this

    ReadScale=comp("Comp 1").layer(index).transform.scale[0]
    [ReadScale,ReadScale]

    It did not work, but the 2nd row was the problem. I tried adding a new array and setting its value to [ReadScale,ReadScale] and it worked. Maybe this is your problem?

    ReadScale=comp("Comp 1").layer(index).transform.scale[0]
    x = [ReadScale,ReadScale];
    x
  • Filip Vandueren

    September 12, 2020 at 11:29 am

    Hi Mike,

    your example works without a problem for me, both in Legacy Extendscript and Javascript engines. (Mac OS X)

  • Chris Voelz

    September 15, 2020 at 8:03 pm

    This also worked for me.

  • stephen dixon

    September 18, 2020 at 5:32 am

    Maddeningly AE layer indexes start at 1, not zero, so any loops that reference indexes have to start at 1. That could be your problem. Either that or for some reason you’re trying to reference a layer index that doesn’t exist.

    Also

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

    How can this work correctly? You’re missing a bracket on the right hand side, and parseInt is for converting strings into ints.

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