If comp A is sitting in the middle of comp B, you could make the solid S' a child of comp A and then just use the coordinates of solid S, since these coordinates will be relative to the comp-space of the nested comp A. So the expression would be:

Code: Select all

`comp("Comp A").layer("S").transform.position`

If you think about it, if S is at the middle of comp A its coordinates will be [960,540]. In comp B, if S' is the child of the nested comp A then setting its coordinates to [960,540] will put it right over the middle of comp A and thus right over the layer S.

The advantage of this is that if you scale or rotate comp A inside comp B you don't have to change your expression.

If you can't parent the S' layer to comp A in comp B, then you just need to apply an offset, to make up for the fact that the [0,0] point of comp A is not at [0, 0] in comp B. The position of the top left of comp A in comp B is given by the expression

Code: Select all

`[comp("comp A").width - comp("comp B").width, comp("comp A").height - comp("comp B").height] / 2`

which in this case works out to [-448, -252]. So you can calculate the position of S' by simply adding that offset to the position value of layer S thus:

Code: Select all

```
offset = [comp("comp A").width - comp("comp B").width, comp("comp A").height - comp("comp B").height] / 2;
comp("Comp A").layer("S").transform.position + offset
```

or if you want to save some processing at the expense of hard-coding values into your expression:

Code: Select all

`comp("Comp A").layer("S").transform.position - [448, 252]`