Skip to main content
Participant
February 19, 2020
Answered

parent.thisComp.name

  • February 19, 2020
  • 4 replies
  • 8186 views

expression 

"parent.thisComp.name"

 

I want get name from the parent composition. What can i do to make magic happen?

Correct answer Mylenium

There is no such thing. Since a pre-comp can be used a million times in other compositions it can have infinitely many parents. That's a simple logic issue. You have to explicitly reference the parent comp or use some strict naming convention and string processing to filter out whatever comp you want to address.

 

Mylenium

4 replies

www.eva-motion.digital
Participating Frequently
September 7, 2023
comp("parent").layer("child")
nicholasw52485545
Inspiring
September 7, 2023

Thank you, but that's not it. Manually naming a comp or layer is what I'm trying to avoid. The idea is that you have a text layer in a comp. Let's call that comp TEXTHOLDER. The TEXTHOLDER comp is within a comp we'll call JESSICA. We want duplicate JESSICA and have the text layer inside TEXTHOLDER autoname to JESSICA1, JESSICA2 etc. as AE autonames the comps when duplicated. So.. Telling the text layer to be its direct grandparent comp name, without specifying the name of the comp, there must be a way to code its relationship. 

 

 

Community Expert
September 8, 2023

You can retrieve the "name" of any comp or layer or the index (the layer number), but you cannot use an expression to change any property that cannot be animated. If you can't set a keyframe, you cannot change a property with an expression. For example, this expression on a text layer should give you something to start with if you have a Comp named "Test Comp 2" in the project panel and a default Shape layer in the Main Comp.

 

lrNamae = thisLayer.name;
lyrIndex = thisLayer.index;
origContent = text.sourceText;
ref = comp("Test Comp 2");
refName = ref.name;
orphL1 = ref.layer(1);
orphLayer1 = orphL1.name;
ref1Pos = ref.layer(1).position;
rArrow = thisComp.layer("Right Arrow");
rAroPos = rArrow.position;

"This Layer Name: " + lrNamae + "\r" + 
"This Layer Index: " + lyrIndex + "\r" +
"Original Content: " + origContent + "\r" +
"Orphan Comp Name: " + refName + "\r" +
"First Layer in Orphan Comp: " + orphLayer1 + "\r" +
"Orphan Layer 1 Position: " + ref1Pos + "\r" + 
"Arrow Layer Position: " + rAroPos;

 

This is what that might look like:

I have uploaded an AE 22 project file for you to play with. It should give you a starting point. Take note of the fact that Test Comp 2 is only in the Project Panel. You can access any comp in the project with a "comp("Comp Name") argument, then access any layer in that comp and any property that can be animated on that layer. You cannot create a MOGRT using the information in that orphan comp unless it is included in the comp you use as the source in the Extended Graphics panel. 

 

 

 

 

Participant
February 4, 2023

If your intention is to control a property from a composition that is existing as a layer in an other composition, there is a way to refer to the properties in the subcomp via linking the property to an Essential Graphics property. That makes controlling/accessing those possible from outside the composition.

sskaz
Inspiring
September 7, 2023

This is the solution using Essential Graphics properties, but it’s not quite obvious. For example, if you wanted a text layer in a child precomp to update to the parent comp’s name:

 

  1. In the child precomp, create a text layer with the font styles and animated properties you want. The text doesn’t matter.
  2. Expose the Source Text property to Essential Graphics.
  3. In a parent comp, twirl open  Essential Properties → Source Text, and override the Source Text with an expression, such as: thisComp.name.
  4. The child precomp’s text will now update to parent comp’s name, no matter what parent comp it’s in.

 

You can get more creative by linking the Source Text to other dynamic/expression-controlled layers in the parent comp.

nicholasw52485545
Inspiring
September 7, 2023

Thank you, But nope.

So, the essential graphics twirldown doesn't exist in the 'grandfather' comp, only the parent comp. 

 

The question is really about telling a layer to look into the parents parent comp using expressions. Using the essential graphics set up is a bit of a work around for something that should be simple and in ths case isn't. It came from a job I had where there were 50 different football players needing name animations and they kept changin the players. I got bored of changing so I wanted to find a way to change the footballer comp name and the text comp within it would update all the text animation inside. No matter where the text animation comp was it would read the name of the parents container comp - or grandfather comp - without having to specify which named comp it needs to read. Now you could make a spread sheet with the information on and link using json, but seriously who can be bothered with with that. There must be a way of saying to a layer - look at your parent comp, look at its parent comp and take the  current name of it and use that as the source text. So far, no one has had an answer and it's been years.

 

It's more academic at this point and shows some flaws in after effects. There's been no reason so far why it wouldn't work, but I don't think I've explained my question properly. I appreciate you and everyone for trying to solve the problem.

www.eva-motion.digital
Participating Frequently
September 20, 2022

If you name your containing composition "Parent" you can have an expression something like:

comp("Parent").layer("layer's name you want to point to").content("Property you're pointing to i.e 'rectangle 1'").content("Fill ").color

 et viola

nicholasw52485545
Inspiring
September 12, 2023

The 'layer name I want to point to' is undefined, that's the point! 

Mylenium
MyleniumCorrect answer
Legend
February 19, 2020

There is no such thing. Since a pre-comp can be used a million times in other compositions it can have infinitely many parents. That's a simple logic issue. You have to explicitly reference the parent comp or use some strict naming convention and string processing to filter out whatever comp you want to address.

 

Mylenium

nicholasw52485545
Inspiring
March 24, 2021

But, but, but.. if it's not the parent. I mean it's not the controller of the item contained within it is a container. So can the comp or layer inside link to the 'container' comp property. The container comp may change but the parameter exists in each. For example, a comp within a comp contains a text layer. That text layer needs to be named the name of it's 'grandfather' comp. So how might one code the sourceText to say read the name of whatever comp is 2 levels above? for example. It's not exactly a parent in the same relationship as a null object, but the relationship will be there if the comps are stacked.

Inspiring
September 12, 2023

(Edit: I see this got addressed before I got here.)

 

A comp can be used as a layer in multiple comps, so even if there was a way to find out all the comps that have this item as a layer, there wouldn't be single grandfather comp, since which comp is, conceptually, the grandfather at render time would change depending on which instance of the nested comp is being rendered. 

 

A better way to approach this problem would be to use Essential Properties to feed the grandfather comp name down into the instances. This allows you to modify each rendered instance based on the path the renderer takes to get to the comp. Created a text layer (most likely it should be a guide layer, unless you want it to actually render) and add its source text to the Essential Graphics panelt for whichever comp in the path is immediately nested inside the comp whose name you want to access. This will expose that source text property as an Essential Property on the nested comp. You can then apply an expression to that property to access the thisComp.name.

 

This might sound confusing, but the important thing to remember is depending on how your comps are nested, you won't necessarily want to put the Essential Property on the same comp in which you are accessing the name via your text guide layer. You would ONLY do this if this comp is directly nested inside the comp from which you want to get info. The Essentially Property must be on whatever comp is nested directly inside the ancestor comp.