Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Issue Layer Spaces in pre-comps

  • Issue Layer Spaces in pre-comps

    Posted by Santiago Suarez on January 22, 2016 at 8:12 pm

    Hi Everyone,

    I’m not very expert in this expression’s world or even in programming’s world, so I’m going to give some context of my issue so that you can guide me through this process.

    I started a project in which I needed an ‘M_Layer’ within an ‘M_Comp’ that controlled the 3D position of an ‘F_Layer’ within a pre-comp (‘Child_Comp’), so I wrote this simple code in the ‘F_Layer’ position:

    MC = Comp ("M_Comp");
    C = MC.Layer("M_Layer").transform.position;

    In that moment, it worked, if I changed the position of the ‘M_Layer’ within the ‘M_Comp’, the ‘F_Layer’ followed it. But then I added a parent to the ‘M_Layer’ and this change the ‘F_Layer’ place; so I read in forums and tutorials and find the “Layer Spaces” (Complex issue), and find something like this new code to the ‘F_Layer’ position:

    MC = Comp ("M_Comp");
    ML = MC.Layer("M_Layer");

    ML.toWorld(ML.anchorPoint);

    This worked perfect, if I Moved the ‘M_Layer’, the ‘F_Layer’ followed it even if ‘M_Layer’ had parents, so I started to develop my project based on this code, but in the middle of it I decided that ‘Child_Comp’ was going to have a different size than ‘M_Comp’, and what a surprise when the ‘F_Layer’ didn’t behave like I expected.

    I browsed for a spacific case like this but I didn’t find anything, so I tried to understand what I needed and what could be the issue and I thought that probably the problem was the difference between the origin points of both comps in the world space, so I tried to get this difference by getting the world position of the ‘Child_Comp’ as layer of the ‘M_Comp’ so after try and error and read a lot about “layer spaces” I end with this code:

    MC = Comp ("M_Comp");
    CL = MC.Layer("Child_Comp");
    ML = MC.Layer("M_Layer");

    CLW = CL.toWorld([0,0,0]);
    MLW = ML.toWorld(ML.anchorPoint);

    MLW - CLW;

    Now, I’m not sure if the code or even my reasoning is right but actually the code works, if I move the ‘M_Layer’, the ‘F_Layer’ follows it even if the comps have different sizes. Everything looks good, but i’m afraid, I don’t want more surprises in the future, and I need to finish this project.

    Beside this I’ve noticed that when I change the position of the ‘Child_Comp’ layer in the ‘M_Comp’, the ‘F_Layer’ behaves a little bit unexpected, so although I don’t plan to move this layer, I worried about this because I wouldn’t like if I change the comps sizes, add cameras, or something like that, evrything goes to ruin.

    I would like to be sure of this code or change it if necessary, and if my reasoning is wrong, I also would like to know why is this and how to solve it, this would help me to learn and understand more about this “Layer Spaces”.

    I will apreciate any guidance an advise about this. Sorry for this extended info but like I said, is the way I can figure it out all of this issue.

    //This Code is on the 'F_Layer's Position within a 'Child_Comp' pre-comp

    MC = Comp ("M_Comp");
    CL = MC.Layer("Child_Comp");
    ML = MC.Layer("M_Layer");

    CLW = CL.toWorld([0,0,0]);
    MLW = ML.toWorld(ML.anchorPoint);

    MLW - CLW;

    Santiago Suarez replied 10 years, 3 months ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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