Highlighted

Using thisLayer To Ref Parameter In Another Comp

New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

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" I really thought the 3rd option below would have worked. How can I modify this in order to make it run sucessfuly?

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!

Topics

Expressions

Views

35

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Using thisLayer To Ref Parameter In Another Comp

New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

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" I really thought the 3rd option below would have worked. How can I modify this in order to make it run sucessfuly?

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!

Topics

Expressions

Views

36

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Guide ,
Sep 11, 2020

Copy link to clipboard

Copied

ReadScale=comp("MyComp").layer(thisLayer.index).transform.scale[0]

 

should work fine if you actually have a layer in MyComp with the same index as the one with the expression.

 

Dan

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

Thank you so much for the quick reply!

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 cause an error?  Your code (copy and paste) did work if I replaced "thisLayer.index" with a numeric value. So I’m thinking the rest of my coding is good? Feel like I’m missing something else.. Any thoughts?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
New Here ,
Sep 11, 2020

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Guide ,
Sep 11, 2020

Copy link to clipboard

Copied

How many layers does MyComp have? What's the layer index of the layer with the expression?

 

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...