Answers.Body: <p>If I understand what your asking correctly there is a way of doing it.</p>
  
  <p>On the subcomp layer in the main comp add a colour expression control effect (<strong>Effects > Expression Controls > Color</strong>, then control it with an expression so that it's linked to the colour of the colour picker (use the pick whip).</p>
  
  <p>Now in the subcomp itself the colour will be available to expressions if you use the value <code>comp("M01").layer(thisComp.name).effect("Color Control")(1)</code>. </p>
  
  <p>Obviously this will only work if your comps have unique names. Note that you can use regular <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference" rel="nofollow">javascript string methods</a> to handle text manipulation in expressions, so things like regular expressions and string.split and number.toString all work.</p>
  
  <p>Note that expressions, especially expressions that reference multiple comps can really slow AE down. I've often found that something that is technically possible with a gazillion expressions is practically unworkable because every time you move the time slider you get the beachball for half an hour. So where you can, try converting the expressions into keyframes, or pre-rendering.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-20T15:41:19.683Z
Answers.Text: Yeah, that's not what I mean. Imagine a comp called 'Red," within which is nested a comp called 'Circle.' Red has a color picker set to red, and Circle takes its color from Red. Now I want to duplicate Red, call it Blue, and have Circle -- the same Circle precomp, not a copy of it -- become blue when it's nested within 'Blue.' Does that make sense? Apparently it's not possible. Blue would have to be duplicated in order to reference the new parent comp. There is no way for a comp to discover which comp it is nested in.
Answers.UserDisplayName: d0g
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-21T05:57:06.233Z
Answers.Text: Oh, I get it. Sounds like a job for scripting.
Answers.UserDisplayName: stib
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-20T13:31:36.987Z
Answers.LastActivityDate: 2014-08-20T13:31:36.987Z
Answers.UserDisplayName: stib
Answers.Body: <p>You can link properties in different compositions by using an expression like this one.</p>
  
  <pre><code>comp("Comp Name").layer("Layer Name")("Property e.g. Transform")("SubProperty e.g. Position")
  </code></pre>
  
  <p>If the property is more nested you just add another <code>("sub property")</code> until you reach the property you need, just as you would click through the drop down menus.</p>
  
  <p>Also helpful: VideoCopilot recently released a great free script specializing in pre-comping 3D layers in exactly that way. <a href="http://www.videocopilot.net/blog/2014/08/free-script-3d-pre-compose-tutorial/" rel="nofollow">http://www.videocopilot.net/blog/2014/08/free-script-3d-pre-compose-tutorial/</a></p>
  
  <p><strong>Edit:</strong> Regarding the clarification in the comments about using relative selectors for comps.
  Unfortunately not possible per se. You can do it with layers by specifying the index number but a comp doesn't really have a unique parent which makes this rather hard to have a generic selector for comps. If you have a unique procedural naming based on your comp "depth" this might be possible with some advanced expression or maybe script but if you just named them "my cool comp" and "my other cool" comp you can't really make a script for that.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:08:59.287Z
Answers.Text: Sorry, I don't see what that has to do with my question. I need a way to 'dynamically' alter properties within a comp based on the comp within which it is nested.
Answers.UserDisplayName: d0g
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:09:59.800Z
Answers.Text: I.e., I cannot use `Comp("comp name")` because what I really want is `Comp.thisComp.parent`
Answers.UserDisplayName: d0g
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:11:44.147Z
Answers.Text: Ah so you dont mean dynamically in the sense of changing something in the main comp and affecting something in the sub comp but a way to have relative "paths" in your expressions?
Answers.UserDisplayName: timonsku
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:13:58.083Z
Answers.Text: Yeah, pretty much ... like have a subcomp change depending on the comp where it is nested. Apparently not possible ... http://forums.creativecow.net/readpost/227/27710
Answers.UserDisplayName: d0g
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:14:53.683Z
Answers.Text: "relative paths" is a good way to put it.
Answers.UserDisplayName: d0g
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T18:10:39.620Z
Answers.Text: Edited my answer to include the info about relative pathes.
Answers.UserDisplayName: timonsku
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-08-18T16:05:14.510Z
Answers.LastActivityDate: 2014-08-18T18:09:54.437Z
Answers.LastEditDate: 2014-08-18T18:09:54.437Z
Answers.UserDisplayName: timonsku
Answers.Body: <p>Just built a separate &quot;Controller&quot;-Comp with a layer and a a color-picker. Link all subcomps to this color-picker in the controller-comp.
  Now before rendering each batch of Outputs you only need to alter the one &quot;controller&quot;-comp without having multiple Subcomps.
  I know, this way you still cant render all of them at once but it may speed things up...</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-11-09T15:43:05.140Z
Answers.LastActivityDate: 2020-11-09T15:43:05.140Z
Answers.UserDisplayName: user32831
Body: <p>I have a dozen 'main' comps which have a bunch of nested comps. I need to create about 30 versions of each main comp, with different colors.
  The subcomps are animated shapes, which take their color from a color picker in the main comp.
  I would love to avoid having to duplicate all the subcomps 30 times, so I don't have hundreds of copies.</p>
  
  <p>Is there ANY way to allow a nested comp to change based on the comp within which it is nested?</p>
  
  <p>I know there is no "thisComp.parent" option -- since a comp can be nested in many different parents -- but is there a way to "push" a property "down" into a subcomp? Or any clever workaround? Does this make sense?</p>
  
  <p>E.g., main comp "M01" has subcomps "S01a", "S01b", etc. The colors of shapes in S01a etc are based on a color picker in M01.
  I want to duplicate M01 to M02, change the color picker value, and have S01a S01b pick up the new color value, without having to duplicate them to S02a, S02b, etc in order to reference M02.</p>
  
  <p>I'm using True Comp Duplicator, which is a lifesave with its 'update expressions' option ... but my project is over 50MB now, with hundreds of comps, and is unwieldly.</p>
  
  <p>(I cannot use a 'change color' effect in the main comp; there are transparencies &amp; blend modes that would get messed up.)</p>
  
Tags: <after-effects><adobe><after-effects-expressions>
Title: Any way to change properties of subcomp based on parent comp?
UserDisplayName: d0g
ThreadText: # Any way to change properties of subcomp based on parent comp?
  
  (Asked by: username_0 on 2014-08-18)
  
  I have a dozen 'main' comps which have a bunch of nested comps. I need to create about 30 versions of each main comp, with different colors.
  The subcomps are animated shapes, which take their color from a color picker in the main comp.
  I would love to avoid having to duplicate all the subcomps 30 times, so I don't have hundreds of copies.
  
  Is there ANY way to allow a nested comp to change based on the comp within which it is nested?
  
  I know there is no "thisComp.parent" option -- since a comp can be nested in many different parents -- but is there a way to "push" a property "down" into a subcomp? Or any clever workaround? Does this make sense?
  
  E.g., main comp "M01" has subcomps "S01a", "S01b", etc. The colors of shapes in S01a etc are based on a color picker in M01.
  I want to duplicate M01 to M02, change the color picker value, and have S01a S01b pick up the new color value, without having to duplicate them to S02a, S02b, etc in order to reference M02.
  
  I'm using True Comp Duplicator, which is a lifesave with its 'update expressions' option ... but my project is over 50MB now, with hundreds of comps, and is unwieldly.
  
  (I cannot use a 'change color' effect in the main comp; there are transparencies & blend modes that would get messed up.)
  
  **Tags:** after-effects, adobe, after-effects-expressions
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_1 on 2014-08-20. Score: 2
  
  If I understand what your asking correctly there is a way of doing it.
  
  On the subcomp layer in the main comp add a colour expression control effect (**Effects > Expression Controls > Color**, then control it with an expression so that it's linked to the colour of the colour picker (use the pick whip).
  
  Now in the subcomp itself the colour will be available to expressions if you use the value `comp("M01").layer(thisComp.name).effect("Color Control")(1)`.
  
  Obviously this will only work if your comps have unique names. Note that you can use regular [javascript string methods](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference) to handle text manipulation in expressions, so things like regular expressions and string.split and number.toString all work.
  
  Note that expressions, especially expressions that reference multiple comps can really slow AE down. I've often found that something that is technically possible with a gazillion expressions is practically unworkable because every time you move the time slider you get the beachball for half an hour. So where you can, try converting the expressions into keyframes, or pre-rendering.
  
  > **Comments:**
  > **username_0**: Yeah, that's not what I mean. Imagine a comp called 'Red," within which is nested a comp called 'Circle.' Red has a color picker set to red, and Circle takes its color from Red. Now I want to duplicate Red, call it Blue, and have Circle -- the same Circle precomp, not a copy of it -- become blue when it's nested within 'Blue.' Does that make sense? Apparently it's not possible. Blue would have to be duplicated in order to reference the new parent comp. There is no way for a comp to discover which comp it is nested in.  
  > **username_1**: Oh, I get it. Sounds like a job for scripting.  
  
  ---
  
  ### Answer by username_2 on 2014-08-18. Score: 2
  
  You can link properties in different compositions by using an expression like this one.
  
  ```
  comp("Comp Name").layer("Layer Name")("Property e.g. Transform")("SubProperty e.g. Position")
  
  ```
  
  If the property is more nested you just add another `("sub property")` until you reach the property you need, just as you would click through the drop down menus.
  
  Also helpful: VideoCopilot recently released a great free script specializing in pre-comping 3D layers in exactly that way. <http://www.videocopilot.net/blog/2014/08/free-script-3d-pre-compose-tutorial/>
  
  **Edit:** Regarding the clarification in the comments about using relative selectors for comps.
  Unfortunately not possible per se. You can do it with layers by specifying the index number but a comp doesn't really have a unique parent which makes this rather hard to have a generic selector for comps. If you have a unique procedural naming based on your comp "depth" this might be possible with some advanced expression or maybe script but if you just named them "my cool comp" and "my other cool" comp you can't really make a script for that.
  
  > **Comments:**
  > **username_0**: Sorry, I don't see what that has to do with my question. I need a way to 'dynamically' alter properties within a comp based on the comp within which it is nested.  
  > **username_0**: I.e., I cannot use `Comp("comp name")` because what I really want is `Comp.thisComp.parent`  
  > **username_2**: Ah so you dont mean dynamically in the sense of changing something in the main comp and affecting something in the sub comp but a way to have relative "paths" in your expressions?  
  > **username_0**: Yeah, pretty much ... like have a subcomp change depending on the comp where it is nested. Apparently not possible ... http://forums.creativecow.net/readpost/227/27710  
  > **username_0**: "relative paths" is a good way to put it.  
  > **username_2**: Edited my answer to include the info about relative pathes.  
  
  ---
  
  ### Answer by username_3 on 2020-11-09. Score: 0
  
  Just built a separate "Controller"-Comp with a layer and a a color-picker. Link all subcomps to this color-picker in the controller-comp.
  Now before rendering each batch of Outputs you only need to alter the one "controller"-comp without having multiple Subcomps.
  I know, this way you still cant render all of them at once but it may speed things up...
  
  
  ---
  
  