• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
1

parent.thisComp.name

Community Beginner ,
Feb 19, 2020 Feb 19, 2020

Copy link to clipboard

Copied

expression 

"parent.thisComp.name"

 

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

TOPICS
Expressions

Views

4.2K

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
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 19, 2020 Feb 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

Votes

Translate

Translate
LEGEND ,
Feb 19, 2020 Feb 19, 2020

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Explorer ,
Mar 24, 2021 Mar 24, 2021

Copy link to clipboard

Copied

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.

Votes

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
community guidelines
Enthusiast ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

(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.

Votes

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
community guidelines
Explorer ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

This is not 'the correct answer' 

Votes

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
community guidelines
Community Beginner ,
Sep 20, 2022 Sep 20, 2022

Copy link to clipboard

Copied

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

Votes

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
community guidelines
Explorer ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

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

Votes

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
community guidelines
New Here ,
Feb 04, 2023 Feb 04, 2023

Copy link to clipboard

Copied

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.

Votes

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
community guidelines
Explorer ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

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.

Votes

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
community guidelines
Explorer ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

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.

Votes

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
community guidelines
Explorer ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

Let's simplify. 

Inside 'comp 1' is a comp called 'text' 

Inside 'text' is a text layer. The souce text of 'text layer' is 'thisComp.name' Which displays 'text'

How do I code the source text to display the name of the comp 'comp 1'?

 

The goal is to place the 'text' comp into other comps called 'comp 2' 'comp 3' 'comp 4' etc., and have the text layer display the names of these comps, without updating anything manually.

Votes

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
community guidelines
Explorer ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

Other than Essential Graphics, there is no way to pass data downstream in After Effects, as Mylenium explained at the very top of this thread. Each nested/child precomp needs a text layer exposed to Essential Graphics and the parent overrides it; only the very top-level comp uses the expression thisComp.name, while every child precomp pulls from the text layer’s sourceText.

 

The alternative is an automated script that will create and modify all comps and precomps’ text layers. CompsFromSpreadsheet is a good option, Dataclay Templater may be another. JSON/CSV are good for holding the source data, but you’d still need to work out the structure of your csv/json file and write up some expressions to grab the proper row and column index, which I personally find tedious.

Votes

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
community guidelines
Community Beginner ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

comp("parent").layer("child")

Votes

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
community guidelines
Explorer ,
Sep 07, 2023 Sep 07, 2023

Copy link to clipboard

Copied

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. 

 

 

Votes

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
community guidelines
Community Expert ,
Sep 08, 2023 Sep 08, 2023

Copy link to clipboard

Copied

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:

RickGerard_0-1694190420961.gif

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. 

 

 

 

 

Votes

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
community guidelines
Explorer ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

I give up. 

I'm tired of trying to explain this.

One comp looking to its grandparent comp. Not absolute, relative. 

How do I delete this stupid thread?!

Votes

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
community guidelines
Enthusiast ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

I'm sorry if my reply frustrated you, and I really should have read the whole thread before responding. That said, I think you have explained yourself clearly, and given what you want to do, the Essential Graphics solution offered elsewhere really does work once you become familiar with how to set it up. It isn't as clean and simple as just accessing a .parent property, but it is really important to understand that whether a comp is the "parent" of another comp is highly contextual based on which comp is the root of the network of comps being rendered, and expressions can't directly access render-time network structure.

 

I am attaching a very quick and dirty demo project to show you how you can use Essential Properties/Essential Graphics to accomplish what you are trying to do. If you open up the child comp you will see that by itself it has no idea what its parent or grandparent is, because the renderer is starting with the child comp, not any ancestor. Only when it is rendered as a nested layer can the ancestor names be passed down via Essential Properties to tell it about those relationships.

 

I've been working with AE expressions for more than 20 years, and I promise you this is a HUGE improvement over the time before EG was added to AE, when there was literally no way to accomplish this. If you have any more questions about this I'd be glad to go into further detail either here or in a private conversation.

Votes

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
community guidelines
Explorer ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

Thank you, I'm not trying to change a property that can not be animated. I'm trying to acquire the name of a comp and use it.

Votes

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
community guidelines
Community Expert ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

All you have to do to grab the name of any comp in the Project panel is start with this:

ref = comp("The Comp You Want");

// for position:
ref.position;

// for name
ref.name;

The comp you use as a reference (ref = "The Comp You Want") does not have to be in the Main Comp. It just has to be in the project comp unless you are trying to create a MOGRT. If you are creating a MOGRT using the Essential Graphics workspace, then the ref comp must show up in the flowchart of the comp you are using as the source for the MOGRT.

 

It could not be much simpler.

Votes

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
community guidelines
Enthusiast ,
Sep 12, 2023 Sep 12, 2023

Copy link to clipboard

Copied

LATEST

He isn't looking for an absolute reference to the comp name, though. He wants an implicit, relative reference to the name of an ancestor comp. This isn't directly possible, but others have pointed him toward using Essential Properties to get this for a particular render-time instance of a comp.

Votes

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
community guidelines