Skip to main content
Participating Frequently
June 25, 2024
Answered

Add zero to layer position without moving the layer

  • June 25, 2024
  • 3 replies
  • 604 views

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 has been closed for replies.
Correct answer Dan Ebberts

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]);

3 replies

AM_01Author
Participating Frequently
July 3, 2024

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. 

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
June 25, 2024

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]);
Warren Heaton
Community Expert
Community Expert
June 25, 2024

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

 

 

AM_01Author
Participating Frequently
July 3, 2024

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