Skip to main content
YuK1_Works
Inspiring
Aug 4, 2024 4:29 PM UTC
Answered

[Expressions] How to refer to a comp one level above.

Can I reference a composition one level up in Expression?
Main > Level 1 > Level 2.
Is there a way to access a "Level 1" composition from a "Level 2" layer in a flowchart like this?
I would like to specify a composition as "one above" instead of specifying it by name.

YuK1_Works
YuK1_WorksCorrect answer
Inspiring
Dec 3, 2024 11:38 PM UTC

Essential Properties (Essential Graphics) did what I wanted to do.
What I wanted to do by referencing the hierarchy above Comp was to switch what was displayed in Comp.
This was accomplished by adding arbitrary Expression controls to the Essential Properties and applying the appropriate Expression to the layer I wanted to switch the display to.
Since the Essential Properties can be set for each placed layer, this demand was met perfectly.

5 replies

YuK1_Works
YuK1_WorksAuthorCorrect answer
Inspiring
Dec 3, 2024 11:38 PM UTC

Essential Properties (Essential Graphics) did what I wanted to do.
What I wanted to do by referencing the hierarchy above Comp was to switch what was displayed in Comp.
This was accomplished by adding arbitrary Expression controls to the Essential Properties and applying the appropriate Expression to the layer I wanted to switch the display to.
Since the Essential Properties can be set for each placed layer, this demand was met perfectly.

Translate
YuK1_Works
Inspiring
Dec 3, 2024 11:47 PM UTC

An example of doing that:
Add a Dropdown menu control to the Null layer and add the option to toggle the display to the menu.
Add like the following expression to the Opacity of the layer you want to switch the visibility of.

let f = thisComp.layer("Null").effect("Dropdown menu control")(Menu);
// This number ties the choice to the layer.
// Change it appropriately.
let n = 1;
f == n ? 100 : 0;

 

Translate
Participating Frequently
Dec 3, 2024 10:24 PM UTC

I need this too. Would be nice. 

Translate
Dan Ebberts
Community Expert
Community Expert
Dec 3, 2024 10:37 PM UTC

The problem, of course, is that a comp can be nested inside any number of other comps. So what would be the expected result for "parentComp" when that could be anywhere from zero to "n" other comps?

Translate
Dan Ebberts
Community Expert
Community Expert
Aug 4, 2024 5:08 PM UTC

There's no mechanism to reference another comp, other than by name.

Translate