Answers.Body: <p>ah I think i've got it:</p>
  <pre><code>x = thisComp.layer(index-1).position[0];
  y = thisComp.layer(index-1).position[1];
  [x,y]
  </code></pre>
  <p>(I was returning the value of the layer, not the position of that layer)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-03-13T10:46:04.960Z
Answers.LastActivityDate: 2023-03-13T10:46:04.960Z
Answers.UserDisplayName: tomh
Body: <p>I have many shapes that I want to reference to a single comp with a shape in it, in case I need to change them later on.</p>
  <p>The shapes are 2D and in different positions all over my canvas.</p>
  <p>I want to be able to position each comp using the position data from the layer above it.</p>
  <p>When I try to map the position data from the layer above, I get the wrong position.</p>
  <p>What am I doing wrong?</p>
  <p>As a simple example - I want to position the green star in the same place at the pentagon.  The pentagon is pre-comped in a 300x300 comp, but everything is centred.</p>
  <p>I put this in the star's position field:</p>
  <pre><code>x = (index-1);
  y = (index-1);
  [x,y]
  </code></pre>
  <p>And place the star layer below the pentagon layer.</p>
  <p>Why does the star jump to -1,-1?</p>
  <p><a href="https://i.sstatic.net/HjNIF.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/HjNIF.png" alt="grab" /></a></p>
  
Tags: <after-effects><after-effects-expressions><shape>
Title: After Effects expression using Index position isn't working between comps and shapes
UserDisplayName: tomh
ThreadText: # After Effects expression using Index position isn't working between comps and shapes
  
  (Asked by: username_0 on 2023-03-13)
  
  I have many shapes that I want to reference to a single comp with a shape in it, in case I need to change them later on.
  
  The shapes are 2D and in different positions all over my canvas.
  
  I want to be able to position each comp using the position data from the layer above it.
  
  When I try to map the position data from the layer above, I get the wrong position.
  
  What am I doing wrong?
  
  As a simple example - I want to position the green star in the same place at the pentagon. The pentagon is pre-comped in a 300x300 comp, but everything is centred.
  
  I put this in the star's position field:
  
  ```
  x = (index-1);
  y = (index-1);
  [x,y]
  
  ```
  
  And place the star layer below the pentagon layer.
  
  Why does the star jump to -1,-1?
  
  [![grab](https://i.sstatic.net/HjNIF.png)](https://i.sstatic.net/HjNIF.png)
  
  **Tags:** after-effects, after-effects-expressions, shape
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2023-03-13. Score: 0
  
  ah I think i've got it:
  
  ```
  x = thisComp.layer(index-1).position[0];
  y = thisComp.layer(index-1).position[1];
  [x,y]
  
  ```
  
  (I was returning the value of the layer, not the position of that layer)
  
  
  ---
  
  