Getting world transform of layers in a child comp

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
Posts: 1
Joined: May 6th, 2020, 2:53 am

Hello! I'm hoping someone can help me please. I'm writing a generic export script that wants the world positions (and ideally, scale, orientation, opacity if possible) of all the layers in all the comps. I have a main comp and inside that there's a childComp. Inside the childComp there's a bunch of layers, children, etc and in the mainComp I move the entire childComp around.

Currently I do this..."position").expression = "toWorld(anchorPoint);";

for each layer and that works for most things except the layers in the childComp - it just returns the world position inside the childComp. I've also tried this...

var exp = "comp[\"""\"].layer[\"""\"].toWorld(toWorld(anchorPoint));""position").expression = exp;

which would give me something like...

comp["mainComp"].layer["compLayer"].toWorld( toWorld(anchorPoint) );

but that didn't work either and also relies on it only being one comp deep. Ideally this would work for many nested comps.
Is there an expression I can apply on export to calculate the overall world position at all? Or if not, some actual script that I can use instead rather than relying on the expressions?



Post Reply