Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Reference “parent” comp in a pre-comp, without a specific string

  • Reference “parent” comp in a pre-comp, without a specific string

    Posted by Steve Renard on January 25, 2012 at 5:32 pm

    Hi all,

    I have a whole bunch of comps that are all doing more or less the same thing, and each of them has its own pre-comp in which there are two layers that serve as masks to a layer in the main comp. Each of those layers has a mask drawn on it that is currently defined by an expression like the first example below, using a string to reference a specific comp.

    Is there any way to do this that would be similar to the “index” argument, so that instead of writing “comp(“Parent Comp”)”, I could write “comp(compIndex-1)” or something like that? My goal is to be able to duplicate both the main comp and the pre-comp, then drop the new pre-comp into the new main comp and have everything change dynamically, rather than having to go into the expressions in the new pre-comp and change the comp name references.

    Thanks in advance for your help.

    Cheers,
    Steve

    comp("003A_SessionLeader").layer("Head Mask 2").mask("Mask 1").maskPath

    ————
    Steve Renard
    647-406-7991
    st***@*********rd.com

    Steve Renard replied 14 years, 3 months ago 3 Members · 5 Replies
  • 5 Replies
  • Kevin Camp

    January 25, 2012 at 6:54 pm

    i don’t believe there is any comp index reference in the project window, however since you are dropping in a new nested comp into the main comp, you could use the layer index of the nested comp after it replaces the original nested comp to return the name of the comp….

    say the nested comp that gets replaced has a layer index of 2. your expression could look like this:

    comp(layer(2).name).layer(“Head Mask 2”).mask(“Mask 1”).maskPath

    would something like that work? or am i missing what your after…?

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Kevin Camp

    January 25, 2012 at 7:24 pm

    sorry, i got it backwards.. you need the nested comp to reference the parent (hence the title of your post)…

    if the nested comp and the main comp had similar names, then this could be fairly simple… say the nested comp’s name is ‘comp 1’ and the main comps name is ‘main_comp 1’, then your expression could look like this:

    comp(‘main_’+thisComp.name).layer(“Head Mask 2”).mask(“Mask 1”).maskPath

    as you duplicate the comps you’ll need to make sure they keep the naming convention that you decide on. in the naming in the example, simply duplicating the comp would maintain the relationships… comp 1 would become comp 2 and main_comp 1 would become main_comp 2, so that could keep it very simple.

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Steve Renard

    January 25, 2012 at 7:36 pm

    That sounds good – thanks Kevin! Unfortunately I’m rendering at the moment but as soon as it’s done I’ll give that a try.

    Cheers,
    Steve

    ————
    Steve Renard
    647-406-7991
    steve@steverenard.com

  • Dan Ebberts

    January 25, 2012 at 7:55 pm

    You can make it automatic if you’re clever about your comp naming convention. For example, if your main comps are “Comp 1”, “Comp 2”, etc. and your corresponding precomps are “Precomp 1”, “Precomp 2”, etc., an expression in the precomp could calculate the name of its corresponding parent comp like this:

    “Comp ” + thisComp.name.split(” “)[1];

    Dan

  • Steve Renard

    January 27, 2012 at 3:11 pm

    Thanks to you both, Dan and Kevin – your solutions have worked great in this case, and saved me a lot of tedious retyping of comp names in the expressions!

    Cheers,
    Steve

    ————
    Steve Renard
    647-406-7991
    steve@steverenard.com

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy