Skip to main content
Adirai Maji
Inspiring
March 4, 2020
Answered

Is there any expression to get actual position value of a Child layer in composition?

  • March 4, 2020
  • 3 replies
  • 5930 views

Yes the question is straight forward. Let me know if it possible. Thank you.

This topic has been closed for replies.
Correct answer joel pitrel

The way toComp work is that it converts the coordinates of a point on the surface of a layer to its coordinates on the comp's screen so if it is offseted it may be that your targeted layer's anchor point doesn't match the coordinates that are between the toComp's parenthesis if the point you are trying to match is the layer's anchorpoint... and as rick pointed out that only works if you are trying to get a 2D coordinate otherwise you should use toWorld...

3 replies

Michelangelo De Cia
Known Participant
April 29, 2024

Yo! If anyone like me had trouble understanding what is going on with the toComp() function and how to use it, I found this really helpful https://www.youtube.com/watch?v=gSq19gpWwSU

Community Expert
April 9, 2024

The actual Position of a child layer ("Null 1" in this example) is retrieved by using the toWorld(AnchorPoint) function like this:

L = thisComp.layer("Null 1");
pos = L.toComp(anchorPoint);

If you need more than that, we need screenshots with the modified properties of the problem layers. Select the layers, press the 'u' key twice, then take a screenshot of the entire UI and share it.

Inspiring
March 4, 2020
Watch for the toComp() function



Envoyé de mon iPhone
Adirai Maji
Inspiring
March 4, 2020

It works but I've a little issue. Whenever I apply toComp([0,0,0]) it have some  variation in the result. X position differ by 0.5xxxx and Y Position differ by  74.60xxxx  May I know why is it happening?

Community Expert
March 4, 2020
l = thisComp.layer("Null 1");
l.toComp([0,0,0])// returns the position of Null 1 relative to the comp - z axis will not match in 3D layers especially if you start dragging values

l = thisComp.layer("Null 1");
l.toWorld([0,0,0]) // will always match position coordinates for Null 1

Does that make sense? That is how it has always worked.