Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Javascript – access to PreComp # of times used

  • Javascript – access to PreComp # of times used

    Posted by Jose Sancho on April 22, 2017 at 11:42 am

    I want to get some parameters from some selected comps in the project. I need to get if the comps are used inside other comp and substitute them with other comp.

    My final goal is to script the substitution of a precomp with alt+drag . I have a large project and have to do it many times.

    Thanks
    J.

    Dan Ebberts replied 9 years ago 3 Members · 3 Replies
  • 3 Replies
  • Steve Sierra

    April 22, 2017 at 1:51 pm

    Hi,

    There must be a better method, but here’s what I’d do :
    (assuming the selected comps names haven’t been changed in other comps, and other layers don’t have the same name.)

    -For each Comp selected, get name (SelectedCompName)
    -For each comp in the project panel, do a forloop on all the layers to compare the names of each layer(LayerName) with SelectedCompName.
    If LayerName == CompName, then use replaceSource() on the layer.

    As I said, there must be a better method, but I hope this helps in the meantime…

    Good Luck 😉

  • Dan Ebberts

    April 22, 2017 at 6:26 pm

    For each of your selected comps, its usedIn attribute will give an array of comps in which the selected comp appears. You can then search the comps in the array for layers having a source with an id attribute that matches the id of your selected layer
    Dan

  • Dan Ebberts

    April 22, 2017 at 6:28 pm

    For each of your selected comps, its usedIn attribute will give an array of comps in which the selected comp appears. You can then search the comps in the array for layers having a source with an id attribute that matches the id of your selected comp.

    Dan

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