-
If else expression when using position coordinates
Hi Expression Pro’s!
My if else isn’t working, even though I think it should.
Situation?
If the y-position of two layers in a particular comp is the same, nothing should happen.
If the y-position of two layers in a particular comp varies, the y position of ‘the layer with this expression‘ should shift upward 30 pixels.a = comp(“Comp 1”).layer(“Layer 1”).transform.position[1];
b = comp(“Comp 1”).layer(“Layer 2”).transform.position[1];
x = transform.position[0];
y = transform.position[1];if (a = b) {[x, y]} else {[x, y – 30]}
a is not b, but the layer doesn’t go – 30
Context? (Don’t think it makes things much clearer, so maybe don’t read if it’s clear already)
I made an index (like in a book), each chapter a text layer consisting of one line. This is the standard situation. Layer 2 in the comp is actually a pin I created with Pins & Boxes, pinned to Layer 1. If a text layer (chapter) is made up of two lines, the pin goes to the lower left point of the text. (With this I overcame the issue of: the position of the text layer stays the same, but the extra line makes the pin go down which pushes every other chapter down). The next text layer’s (chapter’s) position starts where the pin is, down an extra 30 pixels, to create an enter. Might not be the most straightforward way to do this, but it works exactly as I wanted!There’s just one place in my main comp, where I want to cancel these 30 extra pixels, so to keep something else centered. If the pin isn’t at the same position as the text layer, (which it isn’t if there’s an extra line), this layer with the expression (which is Comp 1) should go back up 30 pixels.
Seems like the right expression to me, but it fails to work.