Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Add zero to layer position without moving the layer

Community Beginner ,
Jun 25, 2024 Jun 25, 2024

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. 

 

 

 
 

 

TOPICS
Expressions , How to
495
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 25, 2024 Jun 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]);
Translate
Community Expert ,
Jun 25, 2024 Jun 25, 2024

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

 

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 03, 2024 Jul 03, 2024
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 25, 2024 Jun 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]);
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 03, 2024 Jul 03, 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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines