Skip to main content
Participating Frequently
Jun 25, 2024 3:33 PM UTC
Answered

Add zero to layer position without moving the layer

With Duik, you can add 0 to a layer and the outcome has 2 guide layers both parented to the target layer while the target layer has a new position of [0,0].

I've spent a couple of hours trying to make chat GPT give me something useful but to no avail.  I know I'm missing something and I just want to understand what I'm getting wrong or what process would allow me to do this manually. 

 

 

eg. Layer 1 has position [1158, 904] I want to make the position value of this layer [0,0] without moving it. 

 

 

 
 

 

This topic is closed to new replies. Start a new post to keep the conversation going.
Dan Ebberts
Dan EbbertsCorrect answer
Community Expert
Jun 25, 2024 4:24 PM UTC

For a 2D layer, I think this works:

var layer = app.project.activeItem.layer(1);
var pos = layer.property("Position").value;
var ap = layer.property("Anchor Point").value;
layer.property("Anchor Point").setValue([ap[0]-pos[0],ap[1]-pos[1]]);
layer.property("Position").setValue([0,0]);

4 replies

AM_01Author
Participating Frequently
Jul 3, 2024 9:51 AM UTC

Hi Dan, thank you for this. Yes, this works for what I was trying to do.
Also apologies for the late reply and, well... thank you for everything you do. A huge portion of what I know and have learned on AE is because of you. You're a legend thanks. 

Translate
Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
Jun 25, 2024 4:24 PM UTC

For a 2D layer, I think this works:

var layer = app.project.activeItem.layer(1);
var pos = layer.property("Position").value;
var ap = layer.property("Anchor Point").value;
layer.property("Anchor Point").setValue([ap[0]-pos[0],ap[1]-pos[1]]);
layer.property("Position").setValue([0,0]);
Translate
Warren Heaton
Community Expert
Community Expert
Jun 25, 2024 4:01 PM UTC

For this, subtract the change to the Position values from the corresponding Anchor Point values.

 

 

Translate
AM_01Author
Participating Frequently
Jul 3, 2024 9:53 AM UTC

Yes, this makes sense, just wasn't sure how.  Thanks for your help much appreciated!

Translate