Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Expression to access an item’s precomp?

  • Expression to access an item’s precomp?

    Posted by Matt Reyer on July 3, 2011 at 4:11 am

    If I use comp(“ExampleComp”) then if I duplicate that comp then the comps inside it that reference “ExampleComp” will still reference the first comp, not “ExampleComp 2”.

    How can I access the composition that my item is inside? There is no function I can find like thisPrecomp or thisParentComp.

    Thanks for your help!

    Matt Reyer replied 14 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    July 3, 2011 at 4:55 am

    There’s no way to reference a “parent” comp, except by name.

    Dan

  • Matt Reyer

    July 3, 2011 at 4:56 am

    Well damn, Adobe! Thanks Dan.

  • Dan Ebberts

    July 3, 2011 at 5:06 am

    It makes sense when you think about the way precomps work. You can’t have a precomp that renders differently in one parent comp than it does in another. If you duplicate the entire chain, you can set your expressions up so that they they use the name of the comp they’re in to reference the parent comp. Say you have Maincomp 1 and Precomp 1. You duplicate those and have Maincomp 2 and Precomp 2. You could have expressions in the precomps that have something like this:

    parentComp = comp(“Maincomp” + parseInt(thisComp.name.split(” “)[1],10));

    The expressions in the precomp would automatically find the matching parent comp.

    Dan

  • Matt Reyer

    July 3, 2011 at 5:13 am

    That’s just the solution I needed! I guess I’m just too used to Object-Oriented programming that I assumed this would be possible in After Effects, but your point makes sense now.

    Thanks man!

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