Activity › Forums › Adobe After Effects › After Effects + JavaScript: How to change the position of a single axis?
-
After Effects + JavaScript: How to change the position of a single axis?
Posted by Conor Grebel on December 3, 2011 at 12:43 amI couldn’t find the answer to this anywhere…
I can see how you run a command to effect all 3 axis at once
myLayer.position.setValue( [ 50, 50, 50 ] );but I want to change only the Z position of a layer, without affecting its current x and y.
is there no position[2]…?
could somebody tell me how to change only the Z axis from javascript?
THANK YOU
Michael Kurz replied 7 years, 9 months ago 7 Members · 18 Replies -
18 Replies
-
Steve Blacker
December 3, 2011 at 3:12 amThe third “50” represents your z position, as far as I can tell…
It’s only work if you’d rather be doing something else…
-
Conor Grebel
December 3, 2011 at 3:19 amyes that much is clear to me. but I want to effect ONLY the z position. if i ran that command then it would effect x y and z. i want the current x and y to remain as they are, and only effect the z position. Please read my original post…
Does that make sense? -
Darby Edelen
December 3, 2011 at 8:38 am[Conor Grebel] “yes that much is clear to me. but I want to effect ONLY the z position. if i ran that command then it would effect x y and z. i want the current x and y to remain as they are, and only effect the z position. Please read my original post…
Does that make sense?”Is this for a script? If you’re working on a script then I don’t have specific code to give you, but I’m much more familiar with expressions where you could handle this like so:
z = 50;
myLayer.position + [0,0,z];
I think similar code should work in a script. Take the current value and add a 3d vector to it. If you want to replace the z value (instead of altering it) then it might be more complicated but still doable. I’d look into javascript array object methods, maybe splice().
Darby Edelen
-
Conor Grebel
December 3, 2011 at 8:56 amyeah i’m looking for script, not expressions. I’ll look into implementing that code but it doesnt work as is…
I’ll keep researching but..thanks anyways! -
Steve Blacker
December 3, 2011 at 12:56 pmCould you separate the x, y and z position parameters on the layer and apply the expression to each? (Right click on the position parameter in the layer timeline)
It’s only work if you’d rather be doing something else…
-
Steve Blacker
December 5, 2011 at 12:06 amYou may have better luck at https://aescripts.com/
It’s only work if you’d rather be doing something else…
-
Gleb Rysanov
December 7, 2011 at 3:07 pmHello Conor,
As far as I understand your question, the goal is to change z position only, leaving x and y dimensions as they are? If so, solution is simple:
x = value;
y = value;
z = (whatever you want it to be);
[x,y,z]or simpler yet:
[value,value,z]
-
Conor Grebel
December 7, 2011 at 10:31 pmNow I know that works or expressions, are you sure that works for JavaScript ? I believe I tried that method but it could not recognize “value”
Reply to this Discussion! Login or Sign Up