2 Replies Latest reply on May 17, 2015 2:03 AM by Mylenium

    Duplicating/Instantiating layers with AE Expressions

    Lachlan D Level 1

      Looking for a way to spawn/create layers with code in AE, add them all to an array then control which frame they stop on in code.


      What I am looking to do is to animate a faux-stop-motion with lego.

      I will take a photo of each block in each position and color, then use expressions to take an area of a source video, find the average color, find the closest lego brick color, then tell me which frame the duplicated comp should stop on.


      Kind of like this, but this was made in JS/HTML

      Dice Painter - YouTube


      To get started with this I need to be able to spawn a bunch of layers in code kind of like the shapes repeater, or the echo effect.

        • 1. Re: Duplicating/Instantiating layers with AE Expressions
          Rick Gerard Adobe Community Professional & MVP

          Expressions can only access a value at time, they cannot scan through a timeline and look for a value then do something with that value. You could control a property like opacity or a frame by using time remapping by referencing a color. There isn't any way to write a single expression that would automatically create a pattern. Expressions are based on Java but they are not as versatile as Java Script.


          For example if you sampled an area of the frame and tied that color sample to a frame of an image sequence which had time remapping applied you could cause a certain frame to be displayed when the color matched the preset. You would have to write a different expression for each color.


          I'd create an image sequence of lego blocks carefully shot to they are in exactly the same position. One frame for each colored block. When you have the image sequence complete you apply time remapping then add your expression. Depending on the complexity of the Lego illustration it would probably take less time to just do this manually. Without seeing a sketch of your idea and having a lot more detail I can't give you much more help than that. The description of your project does not give me much to go on.

          • 2. Re: Duplicating/Instantiating layers with AE Expressions
            Mylenium Most Valuable Participant

            Expressions cannot generate layers. You can only re-position and re-color already existing blocks to mimic the behavior, but even then the sheer number of layers, the color sampling and having to run everything in loops to re-evaluate all parameters with every frame will bring AE to its knees.